Commit 0e75e619 authored by Tebjan Halm's avatar Tebjan Halm
Browse files

Merge pull request #60 from HarkDev/master

Fixed Bound Calculation
parents c1ce332d 02ee6c04
...@@ -47,10 +47,18 @@ namespace Svg ...@@ -47,10 +47,18 @@ namespace Svg
var r = new RectangleF(); var r = new RectangleF();
foreach(var c in this.Children) foreach(var c in this.Children)
{ {
if(c is SvgVisualElement) if (c is SvgVisualElement)
r = RectangleF.Union(r, ((SvgVisualElement)c).Bounds); {
// First it should check if rectangle is empty or it will return the wrong Bounds.
// This is because when the Rectangle is Empty, the Union method adds as if the first values where X=0, Y=0
if (r.IsEmpty)
r = ((SvgVisualElement)c).Bounds;
else
r = RectangleF.Union(r, ((SvgVisualElement)c).Bounds);
}
} }
return r;
return r;
} }
} }
...@@ -81,4 +89,4 @@ namespace Svg ...@@ -81,4 +89,4 @@ namespace Svg
return newObj; return newObj;
} }
} }
} }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment