The Birdfont Source Code


All Repositories / birdfont.git / blobdiff – RSS feed

Fix SVG matrix transforms

Changes made to libbirdfont/Svg/Object.vala

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
--- libbirdfont/Svg/Object.vala +++ libbirdfont/Svg/Object.vala @@ -85,11 +85,11 @@ return "Object"; } - public void fill_and_stroke (Context cr) { + public void paint (Context cr) { Color fill, stroke; bool need_fill = style.fill_gradient != null || style.fill != null; bool need_stroke = style.stroke_gradient != null || style.stroke != null; - + cr.set_line_width (style.stroke_width); if (style.fill_gradient != null) { @@ -131,24 +131,29 @@ g.y1, g.x2, g.y2); + + Matrix gradient_matrix = g.get_matrix (); + gradient_matrix.invert (); + pattern.set_matrix (gradient_matrix); foreach (Stop s in g.stops) { Color c = s.color; pattern.add_color_stop_rgba (s.offset, c.r, c.g, c.b, c.a); } - - pattern.set_matrix (g.get_matrix ()); - + cr.set_source (pattern); } } public void apply_transform (Context cr) { - Matrix matrix = transforms.get_matrix (); - cr.set_matrix (matrix); + Matrix view_matrix = cr.get_matrix (); + Matrix object_matrix = transforms.get_matrix (); + + object_matrix.multiply (object_matrix, view_matrix); + cr.set_matrix (object_matrix); } } }