The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Rotate paths

These changes was commited to the Birdfont repository Sun, 26 Jun 2016 13:23:11 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 26 Jun 2016 13:23:11 +0000 (15:23 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 26 Jun 2016 13:23:11 +0000 (15:23 +0200)
commit ec1a03b0e651858b0b896c2968d8c2ab31d2d7f3
tree 487ad7ca3384535187a0af07232335087db0bcb7
parent e380d7852ccb730f98e8de37d2f2e62405167fc7
Rotate paths

libbirdfont/Path.vala
libbirdfont/ResizeTool.vala
libsvgbird/SvgTransforms.vala
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -2759,9 +2759,45 @@ } else { next.get_left_handle ().move_to_coordinate ( 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; + } } } }
--- a/libbirdfont/ResizeTool.vala +++ b/libbirdfont/ResizeTool.vala @@ -124,13 +124,24 @@ 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 @@ 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); } }
--- a/libsvgbird/SvgTransforms.vala +++ b/libsvgbird/SvgTransforms.vala @@ -40,8 +40,14 @@ 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) {