Clone in a terminal:
Commit e70e405
Johan Mattsson - 2015-06-12T05:55:14+00:00
e70e405588c3bd41714cd3eb1a6606ffd7d5264ejohan.mattsson.m@gmail.com

Set object boundaries

Changed files (2)

Diff

diff --git a/libbirdfont/Layer.vala b/libbirdfont/Layer.valaindex 7a0c39b..5af4043 100644--- a/libbirdfont/Layer.vala+++ b/libbirdfont/Layer.vala@@ -91,7 +91,7 @@ public class Layer : GLib.Object { 			for (int i = 0; i < indent; i++) { 				stdout.printf ("\t"); 			}-			stdout.printf ("Path");+			stdout.printf (@"Path open: $(p.is_open ())"); 			 			if (p.color != null) { 				stdout.printf (" %s", ((!) p.color).to_rgb_hex ());diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex a7e5a74..4a0677e 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -1006,48 +1006,48 @@ public class Path { 		update_region_boundaries (); 	} 	-	private void update_region_boundaries_for_point (EditPoint p) {+	private void update_region_boundaries_for_segment (EditPoint a, EditPoint b) { 		EditPointHandle left_handle; 		EditPointHandle right_handle;+		int steps = 10; 		-		left_handle = p.get_left_handle ();-		right_handle = p.get_right_handle ();+		right_handle = a.get_right_handle ();+		left_handle = b.get_left_handle (); 	-		if (p.x > xmax) {-			xmax = p.x;-		}-		-		if (p.x < xmin) {-			xmin = p.x;-		}--		if (p.y > ymax) {-			ymax = p.y;-		}--		if (p.y < ymin) {-			ymin = p.y;+		if (a.x > xmax || b.x > xmax || left_handle.x > xmax || right_handle.x > xmax) {+			all_of (a, b, (cx, cy) => {+				if (cx > xmax) {+					this.xmax = cx;+				}+				return true;+			}, steps); 		} 		-		update_region_boundaries_for_handle (left_handle);-		update_region_boundaries_for_handle (right_handle);-	}--	private void update_region_boundaries_for_handle (EditPointHandle h) {-		if (h.x > xmax) {-			xmax = h.x;-		}--		if (h.x < xmin) {-			xmin = h.x;+		if (a.x < xmin || b.x < xmin || left_handle.x < xmin || right_handle.x < xmin) {+			all_of (a, b, (cx, cy) => {+				if (cx < xmin) {+					this.xmin = cx;+				}+				return true;+			}, steps); 		} -		if (h.y > ymax) {-			ymax = h.y;+		if (a.y > ymax || b.y > ymax || left_handle.y > xmax || right_handle.y > xmax) {+			all_of (a, b, (cx, cy) => {+				if (cy > ymax) {+					this.ymax = cy;+				}+				return true;+			}, steps); 		} -		if (h.y < ymin) {-			ymin = h.y;+		if (a.y < ymin || b.y < ymin || left_handle.y < xmin || right_handle.y < xmin) {+			all_of (a, b, (cx, cy) => {+				if (cy < ymin) {+					this.ymin = cy;+				}+				return true;+			}, steps); 		} 	} @@ -1064,9 +1064,10 @@ public class Path { 			ymin = 0; 		} -		foreach (EditPoint p in points) {-			update_region_boundaries_for_point (p);-		}+		all_segments ((a, b) => {+			update_region_boundaries_for_segment (a, b);+			return true;+		}); 		 		if (stroke > 0) { 			xmax += stroke;

Contact

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