Clone in a terminal:
Commit bc893cd
Johan Mattsson - 2016-07-09T20:05:36+00:00
bc893cd7d66a76ece205930228fedfa0b51688d7johan.mattsson.m@gmail.com

Last to first in SVG paths

Changed files (3)

Diff

diff --git a/libsvgbird/Doubles.vala b/libsvgbird/Doubles.valaindex 39396b5..d829e3d 100644--- a/libsvgbird/Doubles.vala+++ b/libsvgbird/Doubles.vala@@ -48,6 +48,20 @@ public class Doubles : GLib.Object { 		 		data[index].value = p; 	}++	public void set_type (int index, uchar t) {+		if (unlikely (index < 0)) {+			warning ("index < 0");+			return;+		}++		if (unlikely (index >= size)) {+			warning ("index >= size");+			return;+		}+		+		data[index].type = t;+	} 	 	public void insert (int position, double p) { 		if (capacity < size + 1) {diff --git a/libsvgbird/Points.vala b/libsvgbird/Points.valaindex 97787db..a78b0de 100644--- a/libsvgbird/Points.vala+++ b/libsvgbird/Points.vala@@ -18,13 +18,18 @@ namespace SvgBird {  public class Points : GLib.Object { 	public Doubles point_data = new Doubles.for_capacity (100);-	public bool closed = false;+	public bool closed;+	 	public int size { 		get { 			return point_data.size; 		} 	} 	+	public void set_type (int index, uchar p) {+		point_data.set_type (index, p);+	}+	 	public void set_double (int index, double p) { 		point_data.set_double (index, p); 	}diff --git a/libsvgbird/SvgFile.vala b/libsvgbird/SvgFile.valaindex a015a7f..1e033d9 100644--- a/libsvgbird/SvgFile.vala+++ b/libsvgbird/SvgFile.vala@@ -798,12 +798,17 @@ public class SvgFile : GLib.Object {  		// all instructions are padded +		double first_x = 0;+		double first_y = 0; 		for (int i = 0; i < points_size; i++) { 			// FIXME: add more types 			if (bezier_points[i].type == 'M') {+				first_x = bezier_points[i].x0;+				first_y = bezier_points[i].y0;+				 				points.add_type (POINT_LINE);-				points.add (bezier_points[i].x0);-				points.add (bezier_points[i].y0);+				points.add (first_x);+				points.add (first_y); 				points.add (0); 				points.add (0); 				points.add (0);@@ -850,6 +855,16 @@ public class SvgFile : GLib.Object { 				points.add (rotation); 			} else if (bezier_points[i].type == 'z') { 				points.closed = true;+				+				points.add_type (POINT_LINE);+				points.add (first_x);+				points.add (first_y);+				points.add (0);+				points.add (0);+				points.add (0);+				points.add (0);+				points.add (0);+				 				path_data.add (points); 				points = new Points (); 			} else {

Contact

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