The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Fix polygon

These changes was commited to the Birdfont repository Fri, 15 Jul 2016 19:00:24 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Fri, 15 Jul 2016 19:00:24 +0000]

Updated Files

libsvgbird/Polygon.vala
libsvgbird/SvgFile.vala
libsvgbird/SvgPath.vala
--- a/libsvgbird/Polygon.vala +++ b/libsvgbird/Polygon.vala @@ -19,7 +19,7 @@ public class Polygon : Object { - public Doubles points = new Doubles (); + public Points points = new Points (); public Polygon () { } @@ -27,11 +27,11 @@ public override void draw_outline (Context cr) { return_if_fail (points.size % 2 == 0); - if (points.size > 2) { - cr.move_to (points.data[0].value, points.data[1].value); + if (points.size > 8) { + cr.move_to (points.point_data.get_double (0), points.get_double (1)); - for (int i = 2; i < points.size - 1; i += 2) { - cr.line_to (points.data[i].value, points.data[i + 1].value); + for (int i = 8; i < points.size - 8; i += 8) { + cr.line_to (points.get_double (i + 1), points.get_double (i + 2)); } cr.close_path (); @@ -43,10 +43,8 @@ to_object_view (ref x, ref y); - foreach (Points p in points) { - if (SvgPath.is_over_points (p, point_x, point_y)) { - inside = !inside; - } + if (SvgPath.is_over_points (points, x, y)) { + inside = !inside; } return inside;
--- a/libsvgbird/SvgFile.vala +++ b/libsvgbird/SvgFile.vala @@ -425,8 +425,17 @@ string data = add_separators (attr.get_content ()); string[] point_data = data.split (" "); - foreach (string number in point_data) { - polygon.points.add (parse_number (number)); + for (int i = 0; i < point_data.length - 1; i++) { + string number_x = point_data[i]; + string number_y = point_data[i + 1]; + polygon.points.add_type (POINT_LINE); + polygon.points.add (parse_number (number_x)); + polygon.points.add (parse_number (number_y)); + polygon.points.add (0); + polygon.points.add (0); + polygon.points.add (0); + polygon.points.add (0); + polygon.points.add (0); } } }
--- a/libsvgbird/SvgPath.vala +++ b/libsvgbird/SvgPath.vala @@ -77,7 +77,7 @@ double angle_start, angle_extent, cx, cy; - get_arc_arguments (pen_position_x, pen_position_y, rx, ry, + get_arc_arguments (previous_x, previous_y, rx, ry, rotation, large_arc > 0, sweep > 0, dest_x, dest_y, out angle_start, out angle_extent, out cx, out cy); @@ -184,7 +184,7 @@ } } - public void get_start (Points path, out double x, out double y) { + public static void get_start (Points path, out double x, out double y) { int size = path.point_data.size; x = 0;