The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Store boundaries in SVG coordinates

These changes was commited to the Birdfont repository Wed, 15 Jun 2016 09:48:57 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Wed, 15 Jun 2016 09:48:57 +0000]

Updated Files

libbirdfont/EmbeddedSvg.vala
libbirdfont/PathObject.vala
libsvgbird/Object.vala
libsvgbird/SvgDrawing.vala
--- a/libbirdfont/EmbeddedSvg.vala +++ b/libbirdfont/EmbeddedSvg.vala @@ -26,7 +26,7 @@ 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 override double xmax { + public override double right { get { return x + drawing.width; } @@ -44,8 +44,7 @@ } } - - public override double ymin { + public override double top { get { return y - drawing.height; } @@ -54,7 +53,7 @@ } } - public override double ymax { + public override double bottom { get { return y; }
--- a/libbirdfont/PathObject.vala +++ b/libbirdfont/PathObject.vala @@ -29,55 +29,6 @@ set { 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 () { @@ -128,7 +79,17 @@ } 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) {
--- a/libsvgbird/Object.vala +++ b/libsvgbird/Object.vala @@ -32,11 +32,64 @@ 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; }
--- a/libsvgbird/SvgDrawing.vala +++ b/libsvgbird/SvgDrawing.vala @@ -49,7 +49,7 @@ 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 override double xmax { + public override double right { get { return x + width; } @@ -67,7 +67,7 @@ } } - public override double ymin { + public override double top { get { return y; } @@ -76,7 +76,7 @@ } } - public override double ymax { + public override double bottom { get { return y + height; }