Commit ec1a03b
Rotate paths
Changed files (3)
modifiedlibbirdfont/Path.valamodifiedlibbirdfont/ResizeTool.valamodifiedlibsvgbird/SvgTransforms.vala
Diff
@@ -2761,6 +2761,42 @@ public class Path : GLib.Object { ep.get_right_handle ().x, ep.get_right_handle ().y); } }++ public void transform (Matrix matrix) {+ double x, y;+ EditPointHandle handle;+ + foreach (EditPoint point in points) {+ x = point.x;+ y = point.y;+ + matrix.transform_point (ref x, ref y);+ + point.independent_x = x;+ point.independent_y = y;+ + handle = point.get_right_handle ();+ + x = handle.x;+ y = handle.y;+ + matrix.transform_point (ref x, ref y);+ + handle.independent_x = x;+ handle.independent_y = y;++ handle = point.get_left_handle ();+ + x = handle.x;+ y = handle.y;+ + matrix.transform_point (ref x, ref y);+ + handle.independent_x = x;+ handle.independent_y = y;++ }+ } } }@@ -124,13 +124,24 @@ public class ResizeTool : Tool { update_selection_box (); GlyphCanvas.redraw (); - foreach (SvgBird.Object p in MainWindow.get_current_glyph ().active_paths) {- if (p is PathObject) {- PathObject path = (PathObject) p;- path.get_path ().create_full_stroke ();+ foreach (SvgBird.Object object in MainWindow.get_current_glyph ().active_paths) {+ if (object is PathObject) {+ PathObject path = (PathObject) object;+ Path p = path.get_path ();+ + /*+ Matrix matrix = Matrix.identity ();+ matrix.scale (1, -1);+ matrix.multiply (matrix, object.transforms.get_matrix ());+ matrix.invert ();+ p.transform (matrix);+ object.transforms.clear ();+ */+ + p.create_full_stroke ();+ } else {+ object.transforms.collapse_transforms (); }- - p.transforms.collapse_transforms (); } }); @@ -249,10 +260,12 @@ public class ResizeTool : Tool { x = selection_box_left - svg.x + selection_box_width / 2; y = selection_box_top + svg.y + selection_box_height / 2; p.transforms.rotate (angle, x, y);- } else {- x = selection_box_left + selection_box_width / 2;- y = selection_box_top + selection_box_height / 2;- p.transforms.rotate (angle, x, y);+ } else if (p is PathObject) {+ Path path = ((PathObject) p).get_path ();+ SvgTransforms transform = new SvgTransforms ();+ transform.rotate (-angle, selection_box_center_x, selection_box_center_y);+ Matrix matrix = transform.get_matrix ();+ path.transform (matrix); } } @@ -40,10 +40,16 @@ public class SvgTransforms : GLib.Object { Matrix collapsed = get_matrix (); SvgTransform transform_transform = new SvgTransform.for_matrix (collapsed);- transforms.clear ();+ clear (); add (transform_transform); } + public void clear () {+ transforms.clear ();+ rotation_matrix = Matrix.identity ();+ rotation = 0;+ }+ public void rotate (double theta, double x, double y) { rotation += theta;