The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Click to object matrix transformation

These changes was commited to the Birdfont repository Fri, 15 Jul 2016 18:43:27 +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>
Fri, 15 Jul 2016 18:43:27 +0000 (20:43 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Fri, 15 Jul 2016 18:43:27 +0000 (20:43 +0200)
commit 44838bf4f3adf73d83f1335012a63f78fc5ac93d
tree 307bd77a68598fdeb0c8f7e90d2712a9e6b0d23e
parent 7bf31d87cebbf64827bce0e543a12dcd62f0a9f9
Click to object matrix transformation

Makefile [deleted ]
libsvgbird/Circle.vala
libsvgbird/Ellipse.vala
libsvgbird/Layer.vala
libsvgbird/Object.vala
libsvgbird/Polygon.vala
libsvgbird/Polyline.vala
libsvgbird/Rectangle.vala
libsvgbird/SvgPath.vala
diff --git Makefile(deleted)
--- a/Makefile +++ /dev/null @@ -1,7 +1,1 @@ - all: - ./configure - ./build.py - - install: - ./install.py -d $(DESTDIR)
--- a/libsvgbird/Circle.vala +++ b/libsvgbird/Circle.vala @@ -26,6 +26,7 @@ } public override bool is_over (double x, double y) { + to_object_view (ref x, ref y); double dx = x - cx; double dy = y - cy; return Math.sqrt (dx * dx + dy * dy) <= r;
--- a/libsvgbird/Ellipse.vala +++ b/libsvgbird/Ellipse.vala @@ -28,6 +28,7 @@ } public override bool is_over (double x, double y) { + to_object_view (ref x, ref y); double point_x = x - cx; double point_y = y - cy; return (point_x * point_x) / (rx * rx) + (point_y * point_y) / (ry * ry) <= 1;
--- a/libsvgbird/Layer.vala +++ b/libsvgbird/Layer.vala @@ -31,7 +31,6 @@ objects = new ObjectGroup (); transforms = new SvgTransforms (); } - public override bool update_boundaries (Context cr) { if (objects.size == 0) {
--- a/libsvgbird/Object.vala +++ b/libsvgbird/Object.vala @@ -95,6 +95,12 @@ public virtual bool is_over (double x, double y) { return left <= x <= right && top <= y <= bottom; + } + + public void to_object_view (ref double x, ref double y) { + Matrix m = view_matrix; + m.invert (); + m.transform_point (ref x, ref y); } public abstract void draw_outline (Context cr);
--- a/libsvgbird/Polygon.vala +++ b/libsvgbird/Polygon.vala @@ -41,7 +41,21 @@ cr.close_path (); } } - + + public override bool is_over (double x, double y) { + bool inside = false; + + to_object_view (ref x, ref y); + + foreach (Points p in points) { + if (SvgPath.is_over_points (p, point_x, point_y)) { + inside = !inside; + } + } + + return inside; + } + public override void move (double dx, double dy) { }
--- a/libsvgbird/Polyline.vala +++ b/libsvgbird/Polyline.vala @@ -27,7 +27,7 @@ public override bool is_over (double x, double y) { return false; } - + public override void draw_outline (Context cr) { return_if_fail (points.size % 2 == 0);
--- a/libsvgbird/Rectangle.vala +++ b/libsvgbird/Rectangle.vala @@ -32,6 +32,7 @@ } public override bool is_over (double x, double y) { + to_object_view (ref x, ref y); return this.x <= x <= this.x + width && this.y <= y <= this.y + height; }
--- a/libsvgbird/SvgPath.vala +++ b/libsvgbird/SvgPath.vala @@ -38,15 +38,10 @@ public override bool is_over (double point_x, double point_y) { bool inside = false; - - double x = point_x; - double y = point_y; - - Matrix matrix = view_matrix; - matrix.invert (); - matrix.transform_point (ref x, ref y); if (is_over_boundaries (point_x, point_y)) { + to_object_view (ref point_x, ref point_y); + foreach (Points p in points) { if (is_over_points (p, point_x, point_y)) { inside = !inside; @@ -57,7 +52,7 @@ return inside; } - public bool is_over_points (Points p, double point_x, double point_y) { + public static bool is_over_points (Points p, double point_x, double point_y) { double previous_x; double previous_y; bool inside = false; @@ -136,7 +131,6 @@ if ((next_y > point_y) != (prev_y > point_y) && point_x < (prev_x - next_x) * (point_y - next_y) / (prev_y - next_y) + next_x) { inside = !inside; - print (@"flip\n"); } }