Clone in a terminal:
Commit 9815341
Johan Mattsson - 2015-11-07T16:41:14+00:00
98153415ca1e32336cf8ded9855683873f8fe881johan.mattsson.m@gmail.com

Align stroke to outline

Changed files (3)

Diff

diff --git a/libbirdfont/EditPoint.vala b/libbirdfont/EditPoint.valaindex 307ae13..f08c37d 100644--- a/libbirdfont/EditPoint.vala+++ b/libbirdfont/EditPoint.vala@@ -275,6 +275,11 @@ public class EditPoint : GLib.Object { 		left_handle.process_symmetrical_handle (); 	} 	+	public void to_curve () {+		convert_from_line_to_curve (get_right_handle ());+		convert_from_line_to_curve (get_left_handle ());+	}+	 	public static void convert_from_line_to_curve (EditPointHandle h) { 		switch (h.type) { 			case PointType.LINE_QUADRATIC:diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex 1a549ef..743d81b 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -1548,10 +1548,10 @@ public class Path : GLib.Object { 	public static void get_point_for_step (EditPoint start, EditPoint stop, double step,  		out double x, out  double y) { 		-		PointType right =  PenTool.to_curve (start.type);-		PointType left =  PenTool.to_curve (stop.type);+		PointType right =  PenTool.to_curve (start.get_right_handle ().type);+		PointType left =  PenTool.to_curve (stop.get_left_handle ().type); 		-		if (right == PointType.DOUBLE_CURVE || left == PointType.DOUBLE_CURVE) {+		if (right == PointType.DOUBLE_CURVE && left == PointType.DOUBLE_CURVE) { 			x = double_bezier_path (step, start.x, start.get_right_handle ().x, stop.get_left_handle ().x, stop.x); 			y = double_bezier_path (step, start.y, start.get_right_handle ().y, stop.get_left_handle ().y, stop.y); 		} else if (right == PointType.QUADRATIC && left == PointType.QUADRATIC) {@@ -1564,7 +1564,7 @@ public class Path : GLib.Object { 			x = bezier_path (step, start.x, start.get_right_handle ().x, stop.get_left_handle ().x, stop.x); 			y = bezier_path (step, start.y, start.get_right_handle ().y, stop.get_left_handle ().y, stop.y);	 		} else {-			// warning (@"Mixed point types in segment $(start.x),$(start.y) to $(stop.x),$(stop.y) right: $(right), left: $(left) (start: $(start.type), stop: $(stop.type))");+			warning (@"Mixed point types in segment $(start.x),$(start.y) to $(stop.x),$(stop.y) right: $(right), left: $(left) (start: $(start.type), stop: $(stop.type))"); 			x = bezier_path (step, start.x, start.get_right_handle ().x, stop.get_left_handle ().x, stop.x); 			y = bezier_path (step, start.y, start.get_right_handle ().y, stop.get_left_handle ().y, stop.y);	 		}diff --git a/libbirdfont/StrokeTool.vala b/libbirdfont/StrokeTool.valaindex 6038c51..76675ee 100644--- a/libbirdfont/StrokeTool.vala+++ b/libbirdfont/StrokeTool.vala@@ -520,8 +520,8 @@ public class StrokeTool : GLib.Object { 	 * change when new points are added to a 2x2 path. 	 */ 	void add_double_point_at_intersection (Path pp, EditPoint lep, EditPoint ep) {-		EditPoint before;-		EditPoint after;+		EditPoint prev;+		EditPoint next; 		EditPoint hidden; 		double px, py; 		@@ -531,31 +531,31 @@ public class StrokeTool : GLib.Object { 			return_if_fail (lep.prev != null); 			return_if_fail (lep.next != null); 			-			before = lep.get_prev ();-			after = lep.get_next ();+			prev = lep.get_prev ();+			next = lep.get_next (); 			hidden = new EditPoint (0, 0, PointType.QUADRATIC); 			-			px = before.get_right_handle ().x -				+ (after.get_left_handle ().x - before.get_right_handle ().x) / 2.0;-			py = before.get_right_handle ().y -				+ (after.get_left_handle ().y - before.get_right_handle ().y) / 2.0;+			px = next.get_right_handle ().x +				+ (next.get_left_handle ().x - prev.get_right_handle ().x) / 2.0;+			py = next.get_right_handle ().y +				+ (next.get_left_handle ().y - prev.get_right_handle ().y) / 2.0; 			hidden.independent_x = px; 			hidden.independent_y = py; 			-			hidden.get_right_handle ().x = after.get_left_handle ().x;-			hidden.get_right_handle ().y = after.get_left_handle ().y;-			hidden.get_left_handle ().x = before.get_right_handle ().x;-			hidden.get_left_handle ().y = before.get_right_handle ().y;+			hidden.get_right_handle ().x = next.get_left_handle ().x;+			hidden.get_right_handle ().y = next.get_left_handle ().y;+			hidden.get_left_handle ().x = prev.get_right_handle ().x;+			hidden.get_left_handle ().y = prev.get_right_handle ().y; 			-			pp.add_point_after (hidden, before);+			pp.add_point_after (hidden, prev);  			hidden.get_right_handle ().type = PointType.QUADRATIC; 			hidden.get_left_handle ().type = PointType.QUADRATIC; -			before.get_right_handle ().type = PointType.QUADRATIC;-			after.get_left_handle ().type = PointType.QUADRATIC;-			before.type = PointType.QUADRATIC;-			after.type = PointType.QUADRATIC;+			prev.get_right_handle ().type = PointType.QUADRATIC;+			next.get_left_handle ().type = PointType.QUADRATIC;+			prev.type = PointType.QUADRATIC;+			next.type = PointType.QUADRATIC; 						 			pp.get_closest_point_on_path (lep, ep.x, ep.y, null, null); 		}@@ -2871,7 +2871,7 @@ public class StrokeTool : GLib.Object { 			p1 = path.points.get (i % path.points.size); 			p2 = path.points.get ((i + 1) % path.points.size); 			p3 = path.points.get ((i + 2) % path.points.size);-+			 			if (unlikely (task.is_cancelled ())) { 				return new PathList (); 			}

Contact

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