@@ -37,6 +37,7 @@ class SVGData extends Group {
3737 private static var mURLMatch = ~/ url\( ('| "? )#(. * )\1 \) / ;
3838 private static var mRGBMatch = ~/ rgb\s * \( \s * (\d + )\s * (%)? \s * ,\s * (\d + )\s * (%)? \s * ,\s * (\d + )\s * (%)? \s * \) / ;
3939 private static var defaultFill = FillSolid (0x000000 );
40+ private static var tempMatrix = new Matrix ();
4041
4142 public var height (default , null ): Float ;
4243 public var width (default , null ): Float ;
@@ -121,7 +122,7 @@ class SVGData extends Group {
121122
122123 } else if (mMatrixMatch .match (inTrans )) {
123124
124- var m = new Matrix (
125+ tempMatrix . setTo (
125126 Std .parseFloat (mMatrixMatch .matched (1 )),
126127 Std .parseFloat (mMatrixMatch .matched (2 )),
127128 Std .parseFloat (mMatrixMatch .matched (3 )),
@@ -130,14 +131,9 @@ class SVGData extends Group {
130131 Std .parseFloat (mMatrixMatch .matched (6 ))
131132 );
132133
133- m .concat (ioMatrix );
134+ tempMatrix .concat (ioMatrix );
134135
135- ioMatrix .a = m .a ;
136- ioMatrix .b = m .b ;
137- ioMatrix .c = m .c ;
138- ioMatrix .d = m .d ;
139- ioMatrix .tx = m .tx ;
140- ioMatrix .ty = m .ty ;
136+ ioMatrix .copyFrom (tempMatrix );
141137
142138 scale = Math .sqrt (ioMatrix .a * ioMatrix .a + ioMatrix .c * ioMatrix .c );
143139 } else if (mRotationMatch .match (inTrans )) {
@@ -358,6 +354,21 @@ class SVGData extends Group {
358354 }
359355
360356
357+ private function getMatrix (inNode : Xml , inPrevMatrix : Matrix ): Matrix {
358+
359+ var matrix = inPrevMatrix != null ? inPrevMatrix .clone () : new Matrix ();
360+
361+ if (inNode .exists (" transform" )) {
362+
363+ applyTransform (matrix , inNode .get (" transform" ));
364+
365+ }
366+
367+ return matrix ;
368+
369+ }
370+
371+
361372 private function getStyles (inNode : Xml , inPrevStyles : StringMap <String >): StringMap <String > {
362373
363374 var styles = inPrevStyles != null ? inPrevStyles .copy () : new StringMap <String > ();
@@ -504,14 +515,9 @@ class SVGData extends Group {
504515 }
505516
506517
507- public function loadGroup (g : Group , inG : Xml , matrix : Matrix , inStyles : StringMap <String >): Group {
518+ public function loadGroup (g : Group , inG : Xml , inMatrix : Matrix , inStyles : StringMap <String >): Group {
508519
509- if (inG .exists (" transform" )) {
510-
511- matrix = matrix .clone ();
512- applyTransform (matrix , inG .get (" transform" ));
513-
514- }
520+ var matrix = getMatrix (inG , inMatrix );
515521
516522 if (inG .exists (" inkscape:label" )) {
517523
@@ -534,13 +540,11 @@ class SVGData extends Group {
534540 </g>
535541 </g>
536542 */
543+
537544 if (inG .exists (" opacity" )) {
538545
539546 var opacity = inG .get (" opacity" );
540547
541- if (styles == null )
542- styles = new StringMap <String >();
543-
544548 if (styles .exists (" opacity" ))
545549 opacity = Std .string ( Std .parseFloat (opacity ) * Std .parseFloat (styles .get (" opacity" )) );
546550
@@ -549,10 +553,7 @@ class SVGData extends Group {
549553 }
550554 if (inG .exists (" stroke" )) {
551555
552- var stroke = inG .get (" stroke" );
553-
554- if (styles == null )
555- styles = new StringMap <String >();
556+ var stroke = inG .get (" stroke" );
556557
557558 styles .set (" stroke" , stroke );
558559
@@ -561,19 +562,13 @@ class SVGData extends Group {
561562
562563 var strokeWidth = inG .get (" stroke-width" );
563564
564- if (styles == null )
565- styles = new StringMap <String >();
566-
567565 styles .set (" stroke-width" , strokeWidth );
568566
569567 }
570568 if (inG .exists (" fill" )) {
571569
572570 var fill = inG .get (" fill" );
573571
574- if (styles == null )
575- styles = new StringMap <String >();
576-
577572 styles .set (" fill" , fill );
578573
579574 }
@@ -647,14 +642,9 @@ class SVGData extends Group {
647642 }
648643
649644
650- public function loadPath (inPath : Xml , matrix : Matrix , inStyles : StringMap <String >, inIsRect : Bool , inIsEllipse : Bool , inIsCircle : Bool = false ): Path {
645+ public function loadPath (inPath : Xml , inMatrix : Matrix , inStyles : StringMap <String >, inIsRect : Bool , inIsEllipse : Bool , inIsCircle : Bool = false ): Path {
651646
652- if (inPath .exists (" transform" )) {
653-
654- matrix = matrix .clone ();
655- applyTransform (matrix , inPath .get (" transform" ));
656-
657- }
647+ var matrix = getMatrix (inPath , inMatrix );
658648
659649 var styles = getStyles (inPath , inStyles );
660650 var name = inPath .exists (" id" ) ? inPath .get (" id" ) : " " ;
@@ -755,15 +745,9 @@ class SVGData extends Group {
755745 }
756746
757747
758- public function loadText (inText : Xml , matrix : Matrix , inStyles : StringMap <String >): Text {
759-
760- if (inText .exists (" transform" )) {
761-
762- matrix = matrix .clone ();
763- applyTransform (matrix , inText .get (" transform" ));
764-
765- }
748+ public function loadText (inText : Xml , inMatrix : Matrix , inStyles : StringMap <String >): Text {
766749
750+ var matrix = getMatrix (inText , inMatrix );
767751 var styles = getStyles (inText , inStyles );
768752 var text = new Text ();
769753
0 commit comments