The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Move groups

These changes was commited to the Birdfont repository Mon, 25 Jul 2016 16:08:34 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 25 Jul 2016 16:08:34 +0000 (18:08 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 25 Jul 2016 16:09:44 +0000 (18:09 +0200)
commit 0cdd5611d49f04df82b62507a0a0982e5e154a0d
tree d291b48d7764e86aad50797c257c62759745aeed
parent 0e05f7facf16ba8b0b1f17eb2c5f80f2a367b8b5
Move groups

libsvgbird/Layer.vala
libsvgbird/Object.vala
libsvgbird/SvgDrawing.vala
libsvgbird/SvgFile.vala
libsvgbird/ViewBox.vala
--- a/libsvgbird/Layer.vala +++ b/libsvgbird/Layer.vala @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Johan Mattsson + Copyright (C) 2015 2016 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -31,6 +31,20 @@ objects = new ObjectGroup (); transforms = new SvgTransforms (); } + + public override void move (double dx, double dy) { + left += dx; + right += dx; + top += dy; + bottom += dy; + + foreach (Object object in objects.objects) { + object.move (dx, dy); + } + + update_view_matrix (); + } + public override bool update_boundaries (Context cr) { if (objects.size == 0) {
--- a/libsvgbird/Object.vala +++ b/libsvgbird/Object.vala @@ -294,7 +294,6 @@ parent_matrix = copy_matrix (context.get_matrix ()); apply_transform (context); - view_matrix = copy_matrix (context.get_matrix ()); if (style.fill_gradient != null) { apply_gradient (context, (!) style.fill_gradient); @@ -311,6 +310,8 @@ } draw_outline (context); + + view_matrix = copy_matrix (context.get_matrix ()); context.set_matrix (Matrix.identity ()); if (has_stroke) {
--- a/libsvgbird/SvgDrawing.vala +++ b/libsvgbird/SvgDrawing.vala @@ -28,9 +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 (); + parent_matrix = copy_matrix (cr.get_matrix ()); + base.apply_transform (cr); + apply_view_box (cr); + view_matrix = copy_matrix (cr.get_matrix ()); root_layer.update_boundaries (cr); @@ -39,7 +40,7 @@ top = root_layer.top; bottom = root_layer.bottom; - return true; + return root_layer.right - root_layer.left > 0; } public override bool is_over (double x, double y) { @@ -50,20 +51,25 @@ if (view_box != null) { ViewBox box = (!) view_box; Matrix view_box_matrix = box.get_matrix (width, height); - Matrix view_matrix = cr.get_matrix (); - view_box_matrix.multiply (view_box_matrix, view_matrix); + Matrix object_matrix = cr.get_matrix (); + view_box_matrix.multiply (view_box_matrix, object_matrix); cr.set_matrix (view_box_matrix); } } public override void apply_transform (Context cr) { + Matrix view_matrix = cr.get_matrix (); + Matrix object_matrix = transforms.get_matrix (); + object_matrix.multiply (object_matrix, view_matrix); + cr.set_matrix (object_matrix); + apply_view_box (cr); - base.apply_transform (cr); } public void draw (Context cr) { cr.save (); - apply_transform (cr); + base.apply_transform (cr); + apply_view_box (cr); root_layer.draw (cr); cr.restore (); }
--- a/libsvgbird/SvgFile.vala +++ b/libsvgbird/SvgFile.vala @@ -761,6 +761,8 @@ string[] p = parameters.split (" "); SvgTransform transform = new SvgTransform (); transform.type = TransformType.SCALE; + + print (@"scale $parameters len $(p.length)\n"); if (p.length > 0) { transform.arguments.add (parse_double (p[0]));
--- a/libsvgbird/ViewBox.vala +++ b/libsvgbird/ViewBox.vala @@ -95,7 +95,11 @@ scale_x = original_width / width; scale_y = original_height / height; - bool scale_width = scale_x > scale_y; + print (@"minx miny $minx $miny\n"); + print (@"scale_x > scale_y $scale_x > $scale_y\n"); + print (@"original_width $original_width $width $original_height $height\n"); + + bool scale_width = scale_x * original_height > scale_y * original_width; if (scale_width) { scale = scale_y;