The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Sharp corners (stroke)

These changes was commited to the Birdfont repository Sun, 29 Mar 2015 14:16:51 +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, 29 Mar 2015 14:16:51 +0000 (16:16 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 29 Mar 2015 14:17:11 +0000 (16:17 +0200)
commit 076eba42523e73e4c02ae9772f4dde90c8eaf9b6
tree 62be82a2a0e5fb1273455a916f4c80bf501ba134
parent b3cabc70ba1c0f9bfa949e11d5b19f3d8cf76352
Sharp corners (stroke)

libbirdfont/StrokeTool.vala
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -204,6 +204,7 @@ Path stroked = new Path (); EditPoint start; EditPoint end; + EditPoint previous = new EditPoint (); foreach (EditPoint ep in p.points) { start = ep.copy (); @@ -211,13 +212,16 @@ move_segment (start, end, thickness); + add_corner (stroked, previous, start); + stroked.add_point (start); stroked.add_point (end); - // sharp corner + // line ends around corner start.get_left_handle ().convert_to_line (); end.get_right_handle ().convert_to_line (); - + + previous = end; } stroked.recalculate_linear_handles (); @@ -253,7 +257,30 @@ stroke_stop.independent_x += qx; stroke_stop.independent_y += qy; } + + static void add_corner (Path stroked, EditPoint previous, EditPoint next) { + EditPoint corner; + double corner_x, corner_y; + EditPointHandle previous_handle; + EditPointHandle next_handle; + + previous_handle = previous.get_left_handle (); + next_handle = next.get_right_handle (); + + previous_handle.angle += PI; + next_handle.angle += PI; + + Path.find_intersection_handle (previous_handle, next_handle, out corner_x, out corner_y); + corner = new EditPoint (corner_x, corner_y, PointType.LINE_CUBIC); // FIXME: point type + stroked.add_point (corner); + + previous_handle.angle -= PI; + next_handle.angle -= PI; + } + + } } +