The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix stroked paths

These changes was commited to the Birdfont repository Sun, 06 Mar 2016 13:15:44 +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, 06 Mar 2016 13:15:44 +0000 (14:15 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 06 Mar 2016 13:15:44 +0000 (14:15 +0100)
commit ed856b016f990a07ba598664aaa1026ba7a1608d
tree b79821fa0a8b6e47cbd45b9eb56424d037191ff6
parent 2a621eec02ac3e21b425fe0860cc950351452f48
Fix stroked paths

libbirdfont/Glyph.vala
libbirdfont/Path.vala
libbirdfont/PathObject.vala
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -1653,7 +1653,7 @@ } if (has_path) { - cr.set_fill_rule (FillRule.EVEN_ODD); + cr.set_fill_rule (FillRule.WINDING); Theme.color (cr, "Objects"); cr.fill (); } @@ -1664,6 +1664,14 @@ if (object is PathObject) { PathObject object_path = (PathObject) object; Glyph g = MainWindow.get_current_glyph (); + + if (object_path.path.stroke > 0) { + cr.set_line_width (CanvasSettings.stroke_width / g.view_zoom); + PathObject.draw_path_list (object_path.path.get_stroke_fast (), cr); + Theme.color (cr, "Objects"); + cr.fill (); + } + cr.set_line_width (CanvasSettings.stroke_width / g.view_zoom); object_path.path.draw_path (cr); object_path.path.draw_control_points (cr);
--- a/libbirdfont/Path.vala +++ b/libbirdfont/Path.vala @@ -779,10 +779,6 @@ new_path.highlight_last_segment = highlight_last_segment; return new_path; - } - - public bool is_over_coordinate (double x, double y) { - return is_over_coordinate_var (x, y); } public static double point_distance (EditPoint p1, EditPoint p2) { @@ -839,9 +835,11 @@ } /** Variable precision */ - public bool is_over_coordinate_var (double x, double y) { + public bool is_over_coordinate (double x, double y) { int insides = 0; Path path; + + print (@"is_over_coordinate_var stroke: $stroke\n"); if (stroke > 0) { foreach (Path p in get_stroke_fast ().paths) { @@ -867,11 +865,6 @@ } public bool is_over_boundry (double x, double y) { - if (unlikely (ymin == double.MAX || ymin == 10000)) { - warning ("bounding box is not calculated, run update_region_boundaries first."); - update_region_boundaries (); - } - return (ymin <= y <= ymax) && (xmin <= x <= xmax); }
--- a/libbirdfont/PathObject.vala +++ b/libbirdfont/PathObject.vala @@ -30,7 +30,6 @@ path.stroke = value; } } - // FIXME: flip y axis public override double xmin { @@ -106,7 +105,11 @@ } public void draw_path (Context cr) { - path.draw_path (cr); + if (path.stroke > 0) { + draw_path_list (path.get_completed_stroke (), cr); + } else { + path.draw_path (cr); + } } public static void draw_path_list (PathList pl, Context cr) {