Clone in a terminal:
Commit ad854c9
Johan Mattsson - 2016-06-28T14:45:22+00:00
ad854c9264fac185e5786df1949900305fa42534johan.mattsson.m@gmail.com

Flip SVG objects

Changed files (2)

Diff

diff --git a/libbirdfont/MoveTool.vala b/libbirdfont/MoveTool.valaindex 85cf1c0..d6b7ccc 100644--- a/libbirdfont/MoveTool.vala+++ b/libbirdfont/MoveTool.vala@@ -247,7 +247,7 @@ public class MoveTool : Tool { 		selection_changed (); 	} 	-	public static void update_selection_boundaries () {+	public static void update_selection_boundaries () {		 		get_selection_box_boundaries (out selection_box_center_x, 			out selection_box_center_y, out selection_box_width, 			out selection_box_height, out selection_box_left, @@ -423,50 +423,60 @@ public class MoveTool : Tool { 	} 	 	public static void flip_vertical () {-		flip (true);+		DrawingTools.move_tool.flip (true); 	} 	 	public static void flip_horizontal () {-		flip (false);+		DrawingTools.move_tool.flip (false); 	} -	public static void flip (bool vertical) {-		double xc, yc, xc2, yc2, w, h, l, t;-		double dx, dy;+	public void flip (bool vertical) { 		Glyph glyph = MainWindow.get_current_glyph ();   		-		update_selection_boundaries ();+		update_selection_boundaries ();		 		-		xc = selection_box_center_x;-		yc = selection_box_center_y;+		foreach (SvgBird.Object object in glyph.active_paths) {+			Matrix matrix = Matrix.identity ();+			double x = 0;+			double y = 0;+			+			if (object is EmbeddedSvg) {+				EmbeddedSvg svg = (EmbeddedSvg) object;+				x = selection_box_left - svg.x + selection_box_width / 2;+				y = selection_box_top + svg.y + selection_box_height / 2;+			} else {			+				x = selection_box_center_x;+				y = selection_box_center_y;+			}+			+			matrix.translate (x, y); -		foreach (SvgBird.Object p in glyph.active_paths) {-			if (p is PathObject) {-				Path path = ((PathObject) p).get_path ();-				-				// FIXME: move to object-				if (vertical) {-					path.flip_vertical ();-				} else {-					path.flip_horizontal ();-				}-				+			if (vertical) {+				matrix.scale (1, -1);+			} else {+				matrix.scale (-1, 1);+			}++			matrix.translate (-x, -y);+			+			SvgTransform transform = new SvgTransform.for_matrix (matrix);+			object.transforms.add (transform);+			object.transforms.collapse_transforms ();+			+			if (object is PathObject) {+				Path path = ((PathObject) object).get_path ();+				Matrix m = object.transforms.get_matrix ();+				object.transforms.clear ();+				path.transform (m); 				path.reverse ();+				object.move (0, 0); 			} 		} -		get_selection_box_boundaries (out xc2, out yc2, out w, out h, out l, out t); --		dx = -(xc2 - xc);-		dy = -(yc2 - yc);-		-		foreach (SvgBird.Object p in glyph.active_paths) {-			p.move (dx, dy);-		}-		 		update_selection_boundaries ();-		PenTool.reset_stroke ();+		objects_moved (); 		+		PenTool.reset_stroke (); 		BirdFont.get_current_font ().touch (); 	} 	diff --git a/libbirdfont/ResizeTool.vala b/libbirdfont/ResizeTool.valaindex 58a659b..04b3b7d 100644--- a/libbirdfont/ResizeTool.vala+++ b/libbirdfont/ResizeTool.vala@@ -241,7 +241,7 @@ public class ResizeTool : Tool { 	public static void get_horizontal_reseize_handle_position (out double px, out double py) { 		px = Glyph.reverse_path_coordinate_x (resized_left + resized_width); 		px += 40;-		py = Glyph.reverse_path_coordinate_y (-resized_top - resized_width / 2);+		py = Glyph.reverse_path_coordinate_y (-resized_top - resized_height / 2); 	}  	public static double get_rotated_handle_length () {

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112