Метод intersection
Вычисляет пересечение this и other.
Пересечение двух прямоугольников с выровненными осями, если оно есть, всегда является другим прямоугольником с выровненными осями.
Возвращает пересечение этого и other, или null, если они не пересекаются.
Реализация
Rectangle<num>? intersection(Rectangle<num> other) {
var x0 = max(left, other.left);
var x1 = min(left + width, other.left + other.width);
if (x0 <= x1) {
var y0 = max(top, other.top);
var y1 = min(top + height, other.top + other.height);
if (y0 <= y1) {
return new Rectangle<num>(x0, y0, x1 - x0, y1 - y0);
}
}
return null;
}
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-html/CssRect/intersection.html