Skip to content

Commit 947efb3

Browse files
Gulvan0joshtynjala
authored andcommitted
Correct width/height calculation when viewBox is present
May be connected to the third point in #18
1 parent d46009e commit 947efb3

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

format/svg/SVGData.hx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,30 @@ class SVGData extends Group {
6262
width = getFloatStyle ("width", svg, null, 0.0);
6363
height = getFloatStyle ("height", svg, null, 0.0);
6464

65-
if (width == 0 && height == 0)
66-
width = height = 400;
67-
else if (width == 0)
65+
if (width == 0)
6866
width = height;
6967
else if (height == 0)
7068
height = width;
7169

72-
var viewBox = new Rectangle(0, 0, width, height);
73-
74-
if (svg.exists("viewBox")) {
70+
var viewBox:Rectangle;
7571

72+
if (svg.exists("viewBox"))
73+
{
7674
var vbox = svg.get("viewBox");
7775
var params = vbox.indexOf(",") != -1 ? vbox.split(",") : vbox.split(" ");
7876
viewBox = new Rectangle( trimToFloat(params[0]), trimToFloat(params[1]), trimToFloat(params[2]), trimToFloat(params[3]) );
79-
77+
78+
if (width == 0 && height == 0)
79+
{
80+
width = viewBox.width;
81+
height = viewBox.height;
82+
}
83+
}
84+
else
85+
{
86+
if (width == 0 && height == 0)
87+
width = height = 400;
88+
viewBox = new Rectangle(0, 0, width, height);
8089
}
8190

8291
loadGroup(this, svg, new Matrix (1, 0, 0, 1, -viewBox.x, -viewBox.y), null);

0 commit comments

Comments
 (0)