The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix stroke for paths with double quadratic points

These changes was commited to the Birdfont repository Thu, 16 Apr 2015 08:53:23 +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>
Thu, 16 Apr 2015 08:53:23 +0000 (10:53 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 16 Apr 2015 08:53:23 +0000 (10:53 +0200)
commit b17872bb2c252168a8044fc5dc8fc49f25784576
tree baa127b7389639310a971ce39e7633935c2f9a9a
parent faa58f5a4772b2e5b29f73e02ca7b1efe6faf5d1
Fix stroke for paths with double quadratic points

libbirdfont/EditPoint.vala
libbirdfont/Path.vala
libbirdfont/StrokeTool.vala
--- a/libbirdfont/EditPoint.vala +++ b/libbirdfont/EditPoint.vala @@ -588,9 +588,16 @@ public string to_string () { StringBuilder s = new StringBuilder (); - s.append (@"Position: $x, $y\n"); + + if (deleted) { + s.append (@"Deleted "); + } + + s.append (@"Control point: $x, $y\n"); s.append (@"Left handle: angle: $(left_handle.angle) l: $(left_handle.length)\n"); s.append (@"Right handle: angle: $(right_handle.angle) l: $(right_handle.length)\n"); + s.append (@"Type: $type Left: $(left_handle.type) Right: $(right_handle.type)\n".replace ("BIRD_FONT_POINT_TYPE_", "")); + return s.str; }
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -1153,12 +1153,12 @@ x = first.get_right_handle ().x + (next.get_left_handle ().x - first.get_right_handle ().x) / 2; y = first.get_right_handle ().y + (next.get_left_handle ().y - first.get_right_handle ().y) / 2; - hidden = new EditPoint (x, y, PointType.QUADRATIC); - hidden.right_handle.move_to_coordinate_internal (next.get_left_handle ().x, next.get_left_handle ().y); + hidden = new EditPoint (x, y, PointType.QUADRATIC); hidden.get_right_handle ().type = PointType.QUADRATIC; - hidden.get_left_handle ().type = PointType.QUADRATIC; hidden.type = PointType.QUADRATIC; + + hidden.right_handle.move_to_coordinate_internal (next.get_left_handle ().x, next.get_left_handle ().y); first.get_right_handle ().type = PointType.QUADRATIC; @@ -1297,7 +1297,9 @@ ep.get_right_handle ().set_point_type (PointType.LINE_DOUBLE_CURVE); ep.get_left_handle ().set_point_type (PointType.LINE_DOUBLE_CURVE); ep.type = PointType.DOUBLE_CURVE; - } else + } else { + warning ("Point types: $right and $left in insert_new_point_on_path"); + } ep.get_left_handle ().parent = ep; ep.get_right_handle ().parent = ep;
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -358,16 +358,12 @@ if (path.is_open ()) { first = merged.get_first_point (); last_counter = merged.get_last_point (); - - + first.get_left_handle ().convert_to_line (); first.recalculate_linear_handles (); last_counter.get_right_handle ().convert_to_line (); last_counter.recalculate_linear_handles (); - - first.color = Color.pink (); - last_counter.color = Color.yellow (); } return merged; @@ -1488,7 +1484,7 @@ foreach (EditPoint p in path.points) { if (p.x == point.x && p.y == point.y) { - point.color = Color.pink (); + point.color = Color.green (); // inside = !inside; return false; // FIXME: double check } else if ((p.y > point.y) != (prev.y > point.y) @@ -2026,13 +2022,13 @@ EditPoint start, end, new_point; double px, py; int size, i, added_points; - double step = 0.51; + double step = 0.5; bool open = path.is_open (); - - size = open ? path.points.size - 1 : path.points.size; path.add_hidden_double_points (); + size = open ? path.points.size - 1 : path.points.size; + i = 0; added_points = 0; while (i < size) { @@ -2060,6 +2056,7 @@ && Path.distance (start.x, px, start.y, py) > 0.1 * stroke_width && Path.distance (end.x, px, end.y, py) > 0.1 * stroke_width) { new_point = new EditPoint (px, py); + new_point.prev = start; new_point.next = end; path.insert_new_point_on_path (new_point, step); @@ -2073,12 +2070,8 @@ path.remove_deleted_points (); path.remove_points_on_points (); - - if (stroke_selected) {// FIXME: DELETE - ((!) BirdFont.get_current_font ().get_glyph ("c")).add_path (path); - } } } }