The Birdfont Source Code
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
Sharp corners (stroke)
--- 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;
+ }
+
+
}
}
+