The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Fix more stroke intersections

These changes was commited to the Birdfont repository Wed, 13 May 2015 11:34:09 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Wed, 13 May 2015 11:34:09 +0000]

Updated Files

libbirdfont/Path.vala
libbirdfont/StrokeTool.vala
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -819,8 +819,7 @@ public Path flatten () { Path flat = new Path (); - Glyph g = MainWindow.get_current_glyph (); - + all_of_path ((x, y, t) => { flat.add (x, y); return true;
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -103,7 +103,6 @@ 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); @@ -273,7 +272,7 @@ PathList r = new PathList (); foreach (Path p in pl.paths) { - if (p.points.size > 7) { + if (p.points.size > 22) { r.add (p); } else { has_new_corner (p); @@ -575,8 +574,6 @@ cutoff2.deleted = true; stroked.remove_deleted_points (); - stroked.add (cutoff1.x + (cutoff2.x - cutoff1.x) / 2, cutoff1.y + (cutoff2.y - cutoff1.y) / 2); - return; } @@ -1015,8 +1012,8 @@ Path.find_intersection_point (ep, next, p1, p2, out cross_x, out cross_y); - if (Glyph.CANVAS_MIN < cross_x < Glyph.CANVAS_MAX - && Glyph.CANVAS_MIN < cross_y < Glyph.CANVAS_MAX) { + if (fmin (ep.x, next.x) <= cross_x <= fmax (ep.x, next.x) + && fmin (ep.y, next.y) <= cross_y <= fmax (ep.y, next.y)) { // iterate to find intersection. if (is_line (ep.x, ep.y, cross_x, cross_y, next.x, next.y) && is_line (p1.x, p1.y, cross_x, cross_y, p2.x, p2.y)) { @@ -2021,7 +2018,7 @@ previous.flags |= EditPoint.CURVE_KEEP; previous_inside.flags |= EditPoint.CURVE_KEEP; - + side1.add_point (previous); side2.add_point (previous_inside); } @@ -2117,7 +2114,7 @@ previous.flags |= EditPoint.CURVE_KEEP; previous_inside.flags |= EditPoint.CURVE_KEEP; } - + side1.add_point (previous); side2.add_point (previous_inside); @@ -2213,6 +2210,7 @@ convert_to_curve (side2); side2.reverse (); + pl = merge_stroke_parts (path, side1, side2); }