Skip to content

Commit 3291ede

Browse files
authored
Add Rect.fromPoints (#2799)
Fixes #4926
1 parent 8baa561 commit 3291ede

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎flutter/lib/ui/geometry.dart‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,15 @@ class Rect {
511511
..[3] = center.y + radius;
512512
}
513513

514+
/// Construct the smallest rectangle that encloses the given points.
515+
Rect.fromPoints(Point a, Point b) {
516+
_value
517+
..[0] = math.min(a.x, b.x)
518+
..[1] = math.min(a.y, b.y)
519+
..[2] = math.max(a.x, b.x)
520+
..[3] = math.max(a.y, b.y);
521+
}
522+
514523
static const int _kDataSize = 4;
515524
final Float32List _value = new Float32List(_kDataSize);
516525

0 commit comments

Comments
 (0)