]> O.S.I.I.S - jp/crow.git/commitdiff
dont start bound computation with an empty rect or bounds will always start at (0,0)
authorjpbruyere <jp.bruyere@hotmail.com>
Mon, 15 Feb 2016 13:56:43 +0000 (14:56 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Mon, 15 Feb 2016 13:56:43 +0000 (14:56 +0100)
src/Rectangles.cs

index c507b2bafe0a91f90bb35310631f483971c584b3..5168f3dbc69e40c49a484897b168942a1c852ac1 100644 (file)
@@ -171,11 +171,15 @@ namespace Crow
                Rectangle _bounds;
                bool boundsUpToDate = true;
                public Rectangle Bounds {
-                       get { 
+                       get {
                                if (!boundsUpToDate) {
-                                       _bounds = Rectangle.Empty;
-                                       foreach (Rectangle rInList in list)
-                                               _bounds += rInList;
+                                       if (list.Count > 0) {
+                                               _bounds = list [0];
+                                               for (int i = 1; i < list.Count; i++) {
+                                                       _bounds += list [i];
+                                               }
+                                       } else
+                                               _bounds = Rectangle.Empty;
                                        boundsUpToDate = true;
                                }
                                return _bounds;