From 6bf2152a6b0e762a9cbd27f71bbda9ba36ac92ce Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Tue, 1 Mar 2016 10:46:25 -0800 Subject: [PATCH] Add Rect.fromCircle As requested. --- sky/engine/core/painting/Rect.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sky/engine/core/painting/Rect.dart b/sky/engine/core/painting/Rect.dart index c13026ef533..4e133649a16 100644 --- a/sky/engine/core/painting/Rect.dart +++ b/sky/engine/core/painting/Rect.dart @@ -27,6 +27,15 @@ class Rect { ..[3] = top + height; } + /// Construct a rectangle that bounds the given circle. + Rect.fromCircle({ Point center, double radius }) { + _value + ..[0] = center.x - radius + ..[1] = center.y - radius + ..[2] = center.x + radius + ..[3] = center.y + radius; + } + static const int _kDataSize = 4; final Float32List _value = new Float32List(_kDataSize);