Commit ae45a1e
Rotation
Changed files (3)
modifiedlibsvgbird/SvgFile.valamodifiedlibsvgbird/SvgTransform.valamodifiedlibsvgbird/SvgTransforms.vala
Diff
@@ -680,6 +680,9 @@ public class SvgFile : GLib.Object { transform_functions.add (matrix (functions[i])); } + if (functions[i].has_prefix ("rotate")) {+ transform_functions.add (rotate (functions[i]));+ } // TODO: rotate etc. } @@ -739,6 +742,19 @@ public class SvgFile : GLib.Object { return n; } + private static SvgTransform rotate (string function) {+ string parameters = get_transform_parameters (function);+ string[] p = parameters.split (" ");+ SvgTransform transform = new SvgTransform ();+ transform.type = TransformType.ROTATE;++ if (p.length > 0) {+ transform.arguments.add (parse_double (p[0]));+ }++ return transform;+ }+ private static SvgTransform scale (string function) { string parameters = get_transform_parameters (function); string[] p = parameters.split (" ");@@ -21,7 +21,8 @@ public enum TransformType { NONE, TRANSLATE, MATRIX,- SCALE+ SCALE,+ ROTATE } public class SvgTransform : GLib.Object {@@ -67,7 +68,14 @@ public class SvgTransform : GLib.Object { matrix = Matrix.identity (); - if (type == TransformType.SCALE) {+ if (type == TransformType.ROTATE) {+ if (arguments.size == 1) {+ double r = arguments.get_double (0);+ r *= Math.PI / 180;+ matrix.rotate (r);+ return matrix;+ }+ } else if (type == TransformType.SCALE) { if (arguments.size == 1) { double s = arguments.get_double (0); matrix.scale (s, s);@@ -32,6 +32,14 @@ public class SvgTransforms : GLib.Object { size_matrix = Matrix.identity (); } + public double get_rotation () {+ Matrix m = get_matrix ();+ double w = 1;+ double h = 1;+ m.transform_distance (ref w, ref h);+ return Math.atan2 (h, w);+ }+ public void collapse_transforms () { Matrix collapsed = get_matrix ();