Clone in a terminal:
Commit 47fa1bc
Johan Mattsson - 2016-06-15T09:48:57+00:00
47fa1bc857f78392c77814939c3b58cf8b3c2790johan.mattsson.m@gmail.com

Store boundaries in SVG coordinates

Changed files (4)

Diff

diff --git a/libbirdfont/EmbeddedSvg.vala b/libbirdfont/EmbeddedSvg.valaindex 879af69..f7f2f61 100644--- a/libbirdfont/EmbeddedSvg.vala+++ b/libbirdfont/EmbeddedSvg.vala@@ -26,7 +26,7 @@ public class EmbeddedSvg : SvgBird.Object { 	public double x { get; set; } 	public double y { get; set; } -	public override double xmin {+	public override double left { 		get { 			return x; 		}@@ -35,7 +35,7 @@ public class EmbeddedSvg : SvgBird.Object { 		} 	} -	public override double xmax {+	public override double right { 		get { 			return x + drawing.width; 		}@@ -44,8 +44,7 @@ public class EmbeddedSvg : SvgBird.Object { 		} 	} 	--	public override double ymin {+	public override double top { 		get { 			return y - drawing.height; 		}@@ -54,7 +53,7 @@ public class EmbeddedSvg : SvgBird.Object { 		} 	} -	public override double ymax {+	public override double bottom { 		get { 			return y; 		}diff --git a/libbirdfont/PathObject.vala b/libbirdfont/PathObject.valaindex 2cd8918..544f3b5 100644--- a/libbirdfont/PathObject.vala+++ b/libbirdfont/PathObject.vala@@ -30,55 +30,6 @@ public class PathObject : SvgBird.Object { 			path.stroke = value; 		} 	}--	// FIXME: flip y axis-	public override double xmin {-		get {-			return path.xmin;-		}--		set {-			path.xmin = value;-		}-		-		default = Glyph.CANVAS_MAX;-	}--	public override double xmax {-		get {-			return path.xmax;-		}--		set {-			path.xmax = value;-		}-		-		default = Glyph.CANVAS_MIN;-	}--	public override double ymin {-		get {-			return path.ymin;-		}--		set {-			path.ymin = value;-		}-		-		default = Glyph.CANVAS_MAX;-	}--	public override double ymax {-		get {-			return path.ymax;-		}--		set {-			path.ymax = value;-		}-		-		default = Glyph.CANVAS_MIN;-	} 		 	public PathObject () { 		base ();@@ -128,7 +79,17 @@ public class PathObject : SvgBird.Object { 	}  	public override void update_region_boundaries () {+		xmin = Glyph.CANVAS_MAX;+		xmax = Glyph.CANVAS_MIN;+		ymin = Glyph.CANVAS_MAX;+		ymax = Glyph.CANVAS_MIN;+ 		path.update_region_boundaries ();+		+		xmin = path.xmin;+		xmax = path.xmax;+		ymin = path.ymin;+		ymax = path.ymax; 	}  	public override void rotate (double theta, double xc, double yc) {diff --git a/libsvgbird/Object.vala b/libsvgbird/Object.valaindex 7efd436..1819dea 100644--- a/libsvgbird/Object.vala+++ b/libsvgbird/Object.vala@@ -32,11 +32,64 @@ public abstract class Object : GLib.Object { 	public virtual Gradient? gradient { get; set; }  	/** Path boundaries */-	public virtual double xmax { get; set; }-	public virtual double xmin { get; set; }-	public virtual double ymax { get; set; }-	public virtual double ymin { get; set; }+	public virtual double left { get; set; }+	public virtual double right { get; set; }+	public virtual double top { get; set; }+	public virtual double bottom { get; set; } 	+	public virtual double boundaries_height { +		get {+			return bottom - top;+		}+	}++	public virtual double boundaries_width { +		get {+			return right - left;+		}+	}++	/** Cartesian coordinates for the old BirdFont system. */+	public double xmax { +		get {+			return right;+		}+		+		set {+			right = value;+		}+	}+	+	public double xmin { +		get {+			return left;+		}+		+		set {+			left = value;+		}+	}++	public double ymin {+		get {+			return top - boundaries_height;+		}+		+		set {+			top = value + boundaries_height;+		}+	}++	public double ymax {+		get {+			return top;+		}+		+		set {+			top = value;+		}+	}+ 	public virtual double rotation { get; set; } 	public virtual double stroke { get; set; } 	public virtual LineCap line_cap { get; set; default = LineCap.BUTT; }diff --git a/libsvgbird/SvgDrawing.vala b/libsvgbird/SvgDrawing.valaindex bbc7756..ba157b2 100644--- a/libsvgbird/SvgDrawing.vala+++ b/libsvgbird/SvgDrawing.vala@@ -49,7 +49,7 @@ public class SvgDrawing : Object { 	public double svg_width = 0; 	public double svg_height = 0; -	public override double xmin {+	public override double left { 		get { 			return x; 		}@@ -58,7 +58,7 @@ public class SvgDrawing : Object { 		} 	} -	public override double xmax {+	public override double right { 		get { 			return x + width; 		}@@ -67,7 +67,7 @@ public class SvgDrawing : Object { 		} 	} -	public override double ymin {+	public override double top { 		get { 			return y; 		}@@ -76,7 +76,7 @@ public class SvgDrawing : Object { 		} 	} -	public override double ymax {+	public override double bottom { 		get { 			return y + height; 		}

Contact

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