The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix path iterator

These changes was commited to the Birdfont repository Thu, 28 Jul 2016 13:35:04 +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>
Thu, 28 Jul 2016 13:35:04 +0000 (15:35 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 28 Jul 2016 13:35:04 +0000 (15:35 +0200)
commit 930ed3d23ffa6d1a3c3d4801c4d6c463ee8ba381
tree 0368b7ded8b3a70e56a2b29e4b372c2e49ef4122
parent be6cf8c2e6f11439a462249cea8e01f4384082e2
Fix path iterator

libsvgbird/Points.vala
libsvgbird/SvgPath.vala
--- a/libsvgbird/Points.vala +++ b/libsvgbird/Points.vala @@ -67,7 +67,7 @@ return point_data.get_point_type (index); } - public void all_points (LineIterator iter) { + public void all (LineIterator iter) { double previous_x; double previous_y; @@ -77,8 +77,8 @@ return_if_fail (size % 8 == 0); SvgPath.get_start (this, out previous_x, out previous_y); - - for (int i = 1; i < size; i += 8) { + + for (int i = 8; i < size; i += 8) { switch (points[i].type) { case POINT_ARC: double rx = points[i + 1].value; @@ -102,7 +102,7 @@ double next_x = cx + cos (angle); double next_y = cy + sin (angle); - iter (previous_x, previous_y, next_x, next_y, step, i); + iter (previous_x, previous_y, next_x, next_y, step / steps, i); previous_x = next_x; previous_y = next_y; @@ -113,13 +113,8 @@ points[i + 1].value, points[i + 2].value, points[i + 3].value, points[i + 4].value, points[i + 5].value, points[i + 6].value, - (x, y, t) => { - iter (previous_x, previous_y, x, y, 1, i); - - previous_x = x; - previous_y = y; - return true; - }); + iter, + i); previous_x = points[i + 5].value; previous_y = points[i + 6].value; @@ -178,8 +173,18 @@ return step * (r1 - r0) + r0; } + public static void bezier_vector (double step, double p0, double p1, double p2, double p3, out double a0, out double a1) { + double q0, q1, q2; + + q0 = step * (p1 - p0) + p0; + q1 = step * (p2 - p1) + p1; + q2 = step * (p3 - p2) + p2; + + a0 = step * (q1 - q0) + q0; + a1 = step * (q2 - q1) + q1; + } } }
--- a/libsvgbird/SvgPath.vala +++ b/libsvgbird/SvgPath.vala @@ -53,7 +53,7 @@ public static bool is_over_points (Points p, double point_x, double point_y) { bool inside = false; - p.all_points ((start_x, start_y, end_x, end_y) => { + p.all ((start_x, start_y, end_x, end_y) => { is_inside (ref inside, point_x, point_y, start_x, start_y, end_x, end_y); return true; });