The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

First segment in stroke

These changes was commited to the Birdfont repository Sun, 26 Apr 2015 23:05: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>
Sun, 26 Apr 2015 23:05:23 +0000 (01:05 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 26 Apr 2015 23:49:15 +0000 (01:49 +0200)
commit 43fb3834b4fcf6591b5fe7724d5b48eccc3a7d02
tree 59725cee01dc08c5494df08b87faec7a7b86632b
parent b6e97943d29c105ad2ebcd49da330f608202bcec
First segment in stroke

libbirdfont/StrokeTool.vala
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -276,18 +276,6 @@ last_counter = new EditPoint (); first = new EditPoint (); - - if (path.is_open ()) { - counter.delete_last_point (); - counter.delete_last_point (); - merged.delete_first_point (); - merged.delete_first_point (); - - counter.delete_last_point (); - counter.delete_last_point (); - merged.delete_first_point (); - merged.delete_first_point (); - } merged.append_path (counter); @@ -298,13 +286,14 @@ if (path.is_open ()) { first = merged.get_first_point (); last_counter = merged.get_last_point (); - first.color = Color.pink (); + first.color = Color.pink (); first.get_left_handle ().convert_to_line (); first.recalculate_linear_handles (); last_counter.get_right_handle ().convert_to_line (); last_counter.recalculate_linear_handles (); + last_counter.color = Color.yellow (); } return merged; @@ -2054,27 +2043,29 @@ double x, y, x2, y2, x3, y3, next_x, next_y, step, prev_x, prev_y; double previus_x, previus_y, previus_x2, previus_y2; double previus_middle_x, previus_middle_y; - int size = path.points.size; + int size = path.is_open () ? path.points.size - 1 : path.points.size; bool flat, f, f_next; + int i; side1 = new Path (); side2 = new Path (); - return_val_if_fail (path.points.size > 0, pl); + return_val_if_fail (path.points.size > 1, pl); previous = new EditPoint (); previous_inside = new EditPoint (); - - int i; if (path.is_open ()) { - /* - get_segment (thickness, 0, 0.001, p2, p3, out start); - add_corner (side1, previous, start, p2.copy (), thickness); + p1 = path.points.get (0); + p2 = path.points.get (1 % path.points.size); + + get_segment (thickness, 0, 0.0001, p1, p2, out start); + start.color = Color.green (); + side1.add_point (start.copy ()); - get_segment (-thickness, 0, 0.001, p2, p3, out start); - add_corner (side2, previous_inside, start, p2.copy (), thickness); - */ + get_segment (-thickness, 0, 0.0001, p1, p2, out start); + start.color = Color.blue (); + side2.add_point (start.copy ()); } for (i = 0; i < size; i++) { @@ -2102,21 +2093,21 @@ f_next = is_flat (x, y, x2, y2, x3, y3, 0.01); // FIXME: stroke_width if (!flat && !f_next && step_size > 0.013) { - print (@"Not flat. $step_size\n"); step_size /= 2; continue; } if (flat && f_next && step_size < 0.5) { - print (@"Flat. $step_size\n"); step_size *= 2; continue; } get_segment (thickness, step, step_size, p1, p2, out corner1); get_segment (-thickness, step, step_size, p1, p2, out corner1_inside); + side1.add_point (corner1.copy ()); side2.add_point (corner1_inside.copy ()); + previous = corner1; previous_inside = corner1_inside; @@ -2130,13 +2121,15 @@ previous = corner1; previous_inside = corner1_inside; - get_segment (thickness, 0, 0.001, p2, p3, out start); - add_corner (side1, previous, start, p2.copy (), thickness); + if (!path.is_open () || i < size - 1) { + get_segment (thickness, 0, 0.001, p2, p3, out start); + add_corner (side1, previous, start, p2.copy (), thickness); - get_segment (-thickness, 0, 0.001, p2, p3, out start); - add_corner (side2, previous_inside, start, p2.copy (), thickness); + get_segment (-thickness, 0, 0.001, p2, p3, out start); + add_corner (side2, previous_inside, start, p2.copy (), thickness); + } } - + side1.recalculate_linear_handles (); side2.recalculate_linear_handles ();