Clone in a terminal:
Commit 930ed3d
Johan Mattsson - 2016-07-28T13:35:04+00:00
930ed3d23ffa6d1a3c3d4801c4d6c463ee8ba381johan.mattsson.m@gmail.com

Fix path iterator

Changed files (2)

Diff

diff --git a/libsvgbird/Points.vala b/libsvgbird/Points.valaindex b7e2a5c..38003d4 100644--- a/libsvgbird/Points.vala+++ b/libsvgbird/Points.vala@@ -67,7 +67,7 @@ public class Points : GLib.Object { 		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 @@ public class Points : GLib.Object { 		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 @@ public class Points : GLib.Object { 					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 @@ public class Points : GLib.Object { 					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,6 +173,16 @@ public class Points : GLib.Object { 		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;+	} }  }diff --git a/libsvgbird/SvgPath.vala b/libsvgbird/SvgPath.valaindex 32536bf..b9895ba 100644--- a/libsvgbird/SvgPath.vala+++ b/libsvgbird/SvgPath.vala@@ -53,7 +53,7 @@ public class SvgPath : Object { 	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; 		});

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112