The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Rotate boundaries

These changes was commited to the Birdfont repository Tue, 26 Jul 2016 11:29:42 +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>
Tue, 26 Jul 2016 11:29:42 +0000 (13:29 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 26 Jul 2016 11:29:42 +0000 (13:29 +0200)
commit afffd091169b6c8719074d7b4ae86438f9f4bde4
tree 7c36645599d38a72333d7c9b48d3727471a5ad05
parent 0cdd5611d49f04df82b62507a0a0982e5e154a0d
Rotate boundaries

libsvgbird/Layer.vala
libsvgbird/Object.vala
libsvgbird/ViewBox.vala
--- a/libsvgbird/Layer.vala +++ b/libsvgbird/Layer.vala @@ -44,7 +44,6 @@ update_view_matrix (); } - public override bool update_boundaries (Context cr) { if (objects.size == 0) {
--- a/libsvgbird/Object.vala +++ b/libsvgbird/Object.vala @@ -308,29 +308,78 @@ } else { context.set_line_width (0); } - - draw_outline (context); view_matrix = copy_matrix (context.get_matrix ()); context.set_matrix (Matrix.identity ()); + draw_outline (context); if (has_stroke) { context.stroke_extents (out x0, out y0, out x1, out y1); } else { context.fill_extents (out x0, out y0, out x1, out y1); } + + double point_x0 = x0; + double point_y0 = y0; + double point_x1 = x1; + double point_y1 = y0; + double point_x2 = x1; + double point_y2 = y1; + double point_x3 = x0; + double point_y3 = y1; + + view_matrix.transform_point (ref point_x0, ref point_y0); + view_matrix.transform_point (ref point_x1, ref point_y1); + view_matrix.transform_point (ref point_x2, ref point_y2); + view_matrix.transform_point (ref point_x3, ref point_y3); context.fill (); context.restore (); - left = x0; - top = y0; - right = x1; - bottom = y1; - + left = min (point_x0, point_x1, point_x2, point_x3); + top = min (point_y0, point_y1, point_y2, point_y3); + right = max (point_x0, point_x1, point_x2, point_x3); + bottom = max (point_y0, point_y1, point_y2, point_y3); + return boundaries_width != 0; } + static double min (double x0, double x1, double x2, double x3) { + double min = x0; + + if (x1 < min) { + min = x1; + } + + if (x2 < min) { + min = x2; + } + + if (x3 < min) { + min = x3; + } + + return min; + } + + static double max (double x0, double x1, double x2, double x3) { + double max = x0; + + if (x1 > max) { + max = x1; + } + + if (x2 > max) { + max = x2; + } + + if (x3 > max) { + max = x3; + } + + return max; + } + public Matrix get_view_matrix () { return view_matrix; }
--- a/libsvgbird/ViewBox.vala +++ b/libsvgbird/ViewBox.vala @@ -94,10 +94,6 @@ matrix.translate (minx, miny); scale_x = original_width / width; scale_y = original_height / height; - - 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;