Commit 44838bf
Click to object matrix transformation
Changed files (9)
deletedMakefilemodifiedlibsvgbird/Circle.valamodifiedlibsvgbird/Ellipse.valamodifiedlibsvgbird/Layer.valamodifiedlibsvgbird/Object.valamodifiedlibsvgbird/Polygon.valamodifiedlibsvgbird/Polyline.valamodifiedlibsvgbird/Rectangle.valamodifiedlibsvgbird/SvgPath.vala
Diff
deleted file mode 100644@@ -1,6 +0,0 @@-all:- ./configure- ./build.py--install:- ./install.py -d $(DESTDIR)@@ -26,6 +26,7 @@ public class Circle : Object { } 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;@@ -28,6 +28,7 @@ public class Ellipse : Object { } 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;@@ -32,7 +32,6 @@ public class Layer : Object { transforms = new SvgTransforms (); } - public override bool update_boundaries (Context cr) { if (objects.size == 0) { return false;@@ -97,6 +97,12 @@ public abstract class Object : GLib.Object { 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); public abstract Object copy ();@@ -41,7 +41,21 @@ public class Polygon : Object { 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) { } @@ -27,7 +27,7 @@ public class Polyline : Object { 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); @@ -32,6 +32,7 @@ public class Rectangle : Object { } 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; } @@ -39,14 +39,9 @@ public class SvgPath : Object { 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 @@ public class SvgPath : Object { 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 @@ public class SvgPath : Object { 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"); } }