The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Align stroke to outline

These changes was commited to the Birdfont repository Sat, 07 Nov 2015 16:39:49 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Sat, 07 Nov 2015 16:39:49 +0000]

Updated Files

libbirdfont/EditPoint.vala
libbirdfont/Path.vala
libbirdfont/StrokeTool.vala
--- a/libbirdfont/EditPoint.vala +++ b/libbirdfont/EditPoint.vala @@ -273,6 +273,11 @@ process_tied_handle (); right_handle.process_symmetrical_handle (); 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) {
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -1548,10 +1548,10 @@ 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 @@ 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); }
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -520,8 +520,8 @@ * 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 @@ 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 @@ 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 (); }