Add Rect.fromPoints (#2799)

Fixes https://github.com/flutter/flutter/issues/4926
This commit is contained in:
Adam Barth 2016-07-15 08:32:59 -07:00 committed by GitHub
parent 8baa5615fe
commit 3291edef41

View File

@ -511,6 +511,15 @@ class Rect {
..[3] = center.y + radius;
}
/// Construct the smallest rectangle that encloses the given points.
Rect.fromPoints(Point a, Point b) {
_value
..[0] = math.min(a.x, b.x)
..[1] = math.min(a.y, b.y)
..[2] = math.max(a.x, b.x)
..[3] = math.max(a.y, b.y);
}
static const int _kDataSize = 4;
final Float32List _value = new Float32List(_kDataSize);