The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Faster stroke

These changes was commited to the Birdfont repository Sat, 09 May 2015 16:34:39 +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>
Sat, 09 May 2015 16:34:39 +0000 (18:34 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sat, 09 May 2015 17:02:09 +0000 (19:02 +0200)
commit dcd70d3e3114f34abb8a258e8414104a57f54c03
tree 374bbd5e07692a227e958e62cf174a68864ac355
parent cda412382a84b25e201e4637e27a6c11ac82ca2a
Faster stroke

libbirdfont/StrokeTool.vala
libbirdfont/TrackTool.vala
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -23,6 +23,7 @@ public static bool add_stroke = false; public static bool show_stroke_tools = false; + public static bool convert_stroke = false; public StrokeTool (string tooltip) { } @@ -31,7 +32,8 @@ public static void stroke_selected_paths () { Glyph g = MainWindow.get_current_glyph (); PathList paths = new PathList (); - + + convert_stroke = true; g.store_undo_state (); foreach (Path p in g.active_paths) { @@ -58,6 +60,7 @@ } PenTool.update_orientation (); + convert_stroke = false; } public PathList merge_selected_paths () { @@ -75,19 +78,14 @@ } public static PathList get_stroke_fast (Path path, double thickness) { - PathList o, m; + PathList o; Path stroke; stroke = path.copy (); stroke.remove_points_on_points (0.3); o = create_stroke (stroke, thickness, false); // set to true for faster stroke - - m = new PathList (); - foreach (Path p in o.paths) { - m.add (simplify_stroke (p)); - } - - return m; + + return o; } public static PathList get_stroke (Path path, double thickness) { @@ -97,6 +95,7 @@ stroke = path.copy (); stroke.remove_points_on_points (0.3); o = create_stroke (stroke, thickness, false); + o = get_all_parts (o); o = remove_intersection_paths (o); o = merge (o); @@ -188,7 +187,9 @@ simplified.append_path (added_segment); - if (ep_start.get_right_handle ().is_line ()) { + if (ep_start.get_right_handle ().is_line () + && added_segment.points.size > 0) { + first = added_segment.get_first_point (); first.get_right_handle ().convert_to_line (); first.recalculate_linear_handles (); @@ -1909,8 +1910,8 @@ previous = start.copy (); previous_inside = start_inside.copy (); - previous.flags |= EditPoint.CURVE; - previous_inside.flags |= EditPoint.CURVE; + previous.flags |= EditPoint.CURVE | EditPoint.SEGMENT_END; + previous_inside.flags |= EditPoint.CURVE | EditPoint.SEGMENT_END; side1.add_point (previous); side2.add_point (previous_inside); @@ -1999,8 +2000,8 @@ previous_inside.get_right_handle ().length *= step_size; previous_inside.get_left_handle ().length *= step_size; - previous.flags |= EditPoint.CURVE; - previous_inside.flags |= EditPoint.CURVE; + previous.flags |= EditPoint.CURVE | EditPoint.SEGMENT_END; + previous_inside.flags |= EditPoint.CURVE | EditPoint.SEGMENT_END; side1.add_point (previous); side2.add_point (previous_inside); @@ -2095,20 +2096,26 @@ path.remove_points_on_points (); foreach (EditPoint ep in path.points) { - if ((ep.flags & EditPoint.CURVE) > 0 || (ep.flags & EditPoint.CURVE_KEEP) > 0) { - ep.convert_to_curve (); + if ((ep.flags & EditPoint.SEGMENT_END) == 0) { + if ((ep.flags & EditPoint.CURVE) > 0 || (ep.flags & EditPoint.CURVE_KEEP) > 0) { + ep.convert_to_curve (); + } } } foreach (EditPoint ep in path.points) { - if ((ep.flags & EditPoint.CURVE) > 0 || (ep.flags & EditPoint.CURVE_KEEP) > 0) { - ep.set_tie_handle (true); + if ((ep.flags & EditPoint.SEGMENT_END) == 0) { + if ((ep.flags & EditPoint.CURVE) > 0 || (ep.flags & EditPoint.CURVE_KEEP) > 0) { + ep.set_tie_handle (true); + } } } foreach (EditPoint ep in path.points) { - if ((ep.flags & EditPoint.CURVE) > 0 || (ep.flags & EditPoint.CURVE_KEEP) > 0) { - ep.process_tied_handle (); + if ((ep.flags & EditPoint.SEGMENT_END) == 0) { + if ((ep.flags & EditPoint.CURVE) > 0 || (ep.flags & EditPoint.CURVE_KEEP) > 0) { + ep.process_tied_handle (); + } } } } @@ -2133,7 +2140,7 @@ corner2 = new EditPoint (x2, y2, type); corner3 = new EditPoint (x3, y3, type); - corner2.convert_to_line (); // FIXME: delete + corner2.convert_to_line (); overlay.add_point (corner1); overlay.add_point (corner2);
--- a/libbirdfont/TrackTool.vala +++ b/libbirdfont/TrackTool.vala @@ -540,7 +540,6 @@ p = glyph.path_list.get (glyph.path_list.size - 1); if (added_points == 0) { // last point - warning ("No points"); return; }