The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix ellipse

These changes was commited to the Birdfont repository Sat, 28 Sep 2019 17:31:54 +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>
Sat, 28 Sep 2019 17:31:54 +0000 (19:31 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sat, 28 Sep 2019 17:31:54 +0000 (19:31 +0200)
commit 17daa9446d42a08ff72e77ce082502d4f78a9094
tree e33e60d17d5f57b31f4d5444edb5b67c9a9200b0
parent 642c451408ac508915a8f33df7084ed25887ddf6
Fix ellipse

libbirdfont/CircleTool.vala
--- a/libbirdfont/CircleTool.vala +++ b/libbirdfont/CircleTool.vala @@ -140,31 +140,23 @@ return path; } - + public static Path create_ellipse (double x, double y, - double rx, double ry, PointType pt) { + double rx, double ry, PointType point_type) { - double px, py; - Path path = new Path (); - double steps = (pt == PointType.QUADRATIC) ? PI / 8 : PI / 4; + Path path = create_circle (x, y, 1, point_type); + + SvgTransforms transforms = new SvgTransforms (); + transforms.resize (rx, ry, x, y); - for (double angle = 0; angle < 2 * PI; angle += steps) { - px = rx * cos (angle) + x; - py = ry * sin (angle) + y; - path.add (px, py); + transforms.collapse_transforms (); + Matrix m = transforms.get_matrix (); + path.transform (m); + + foreach (EditPoint ep in path.points) { + ep.set_tie_handle (true); } - path.init_point_type (pt); - path.close (); - path.recalculate_linear_handles (); - - for (int i = 0; i < 3; i++) { - foreach (EditPoint ep in path.points) { - ep.set_tie_handle (true); - ep.process_tied_handle (); - } - } - return path; }