The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Fix view matrix

These changes was commited to the Birdfont repository Sun, 24 Jul 2016 20:22:55 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Sun, 24 Jul 2016 20:22:55 +0000]

Updated Files

libsvgbird/Layer.vala
libsvgbird/Object.vala
libsvgbird/SvgDrawing.vala
libsvgbird/SvgFile.vala
libsvgbird/SvgTransforms.vala
--- a/libsvgbird/Layer.vala +++ b/libsvgbird/Layer.vala @@ -43,22 +43,17 @@ right = CANVAS_MIN; cr.save (); - + parent_matrix = copy_matrix (cr.get_matrix ()); + apply_transform (cr); + view_matrix = copy_matrix (cr.get_matrix ()); + foreach (Object object in objects) { bool has_size = false; - - cr.save (); if (object is Layer) { Layer sublayer = (Layer) object; - object.parent_matrix = cr.get_matrix (); - sublayer.apply_transform (cr); - object.view_matrix = cr.get_matrix (); has_size = sublayer.update_boundaries (cr); } else { - object.parent_matrix = cr.get_matrix (); - object.apply_transform (cr); - object.view_matrix = cr.get_matrix (); has_size = object.update_boundaries (cr); } @@ -67,9 +62,7 @@ right = fmax (right, object.right); top = fmin (top, object.top); bottom = fmax (bottom, object.bottom); - } - - cr.restore (); + } } cr.restore (); @@ -87,6 +80,8 @@ private void draw_layer (Context cr, bool paint) { cr.save (); + + apply_transform (cr); if (clip_path != null) { ClipPath clipping = (!) clip_path; @@ -103,8 +98,7 @@ if (object is Layer) { Layer sublayer = (Layer) object; - sublayer.apply_transform (cr); - + if (paint) { sublayer.draw (cr); } else { @@ -144,7 +138,7 @@ foreach (Object object in objects) { if (object is Layer) { Layer sublayer = (Layer) object; - sublayer.remove (o);; + sublayer.remove (o); } }
--- a/libsvgbird/Object.vala +++ b/libsvgbird/Object.vala @@ -84,8 +84,8 @@ } } - public const double CANVAS_MAX = 100000; - public const double CANVAS_MIN = -100000; + public const double CANVAS_MAX = 1000000; + public const double CANVAS_MIN = -1000000; public Matrix view_matrix = Matrix.identity (); public Matrix parent_matrix = Matrix.identity (); @@ -289,9 +289,12 @@ public virtual bool update_boundaries (Context context) { double x0, y0, x1, y1; bool has_stroke = style.has_stroke (); + + context.save (); + parent_matrix = copy_matrix (context.get_matrix ()); apply_transform (context); - view_matrix = context.get_matrix (); + view_matrix = copy_matrix (context.get_matrix ()); if (style.fill_gradient != null) { apply_gradient (context, (!) style.fill_gradient); @@ -308,8 +311,6 @@ } draw_outline (context); - - context.save (); context.set_matrix (Matrix.identity ()); if (has_stroke) { @@ -317,8 +318,6 @@ } else { context.fill_extents (out x0, out y0, out x1, out y1); } - - context.set_matrix (view_matrix); context.fill (); context.restore (); @@ -340,8 +339,12 @@ Context context = new Cairo.Context (surface); context.set_matrix (parent_matrix); return update_boundaries (context); + } + + public Matrix copy_matrix (Matrix m) { + return new Matrix (m.xx, m.yx, m.xy, m.yy, m.x0, m.y0); } } }
--- a/libsvgbird/SvgDrawing.vala +++ b/libsvgbird/SvgDrawing.vala @@ -28,7 +28,10 @@ public double height = 0; public override bool update_boundaries (Context cr) { + parent_matrix = cr.get_matrix (); apply_transform (cr); + view_matrix = cr.get_matrix (); + root_layer.update_boundaries (cr); left = root_layer.left; @@ -56,7 +59,6 @@ public override void apply_transform (Context cr) { apply_view_box (cr); base.apply_transform (cr); - root_layer.apply_transform (cr); } public void draw (Context cr) {
--- a/libsvgbird/SvgFile.vala +++ b/libsvgbird/SvgFile.vala @@ -89,6 +89,7 @@ } set_object_properties (drawing, new SvgStyle (), svg_tag); + drawing.update_boundaries_for_object (); return drawing; }
--- a/libsvgbird/SvgTransforms.vala +++ b/libsvgbird/SvgTransforms.vala @@ -30,6 +30,12 @@ transforms = new Gee.ArrayList<SvgTransform> (); rotation_matrix = Matrix.identity (); size_matrix = Matrix.identity (); + } + + public void clear_rotation () { + rotation = 0; + total_rotation = 0; + rotation_matrix = Matrix.identity (); } public double get_rotation () {