From 3291edef4172d81d5f24921f4e9a67dbd5406ead Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 15 Jul 2016 08:32:59 -0700 Subject: [PATCH] Add Rect.fromPoints (#2799) Fixes https://github.com/flutter/flutter/issues/4926 --- flutter/lib/ui/geometry.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/flutter/lib/ui/geometry.dart b/flutter/lib/ui/geometry.dart index a4b03c1e32f..567d0d5431e 100644 --- a/flutter/lib/ui/geometry.dart +++ b/flutter/lib/ui/geometry.dart @@ -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);