Commit fa3ffb3
Merge ../birdfont-2.x
Changed files (3)
modifiedlibbirdfont/BezierTool.valamodifiedlibbirdfont/PenTool.valamodifiedlibbirdfont/PointTool.vala
Diff
@@ -366,21 +366,21 @@ public class BezierTool : Tool { GlyphCanvas.redraw (); } else if (state == MOVE_HANDLE_ON_AXIS) { EditPointHandle h = current_point.get_right_handle ();- double horizontal, vertical;- - vertical = Path.distance (px, h.parent.x, py, py);- horizontal = Path.distance (h.parent.y, py, py, py); current_path.hide_end_handle = false; current_point.set_reflective_handles (true); current_point.convert_to_curve ();- - if (horizontal < vertical) {- h.move_to_coordinate (px, current_point.y);- } else {- h.move_to_coordinate (current_point.x, py);- }- + + double tied_x = 0;+ double tied_y = 0;+ + PointTool.tie_angle (h.parent.x, h.parent.y,+ px, py, out tied_x, out tied_y);+ + h.x = tied_x;+ h.y = tied_y;+ + current_path.reset_stroke (); GlyphCanvas.redraw (); } @@ -833,27 +833,14 @@ public class PenTool : Tool { selected_handle.y = coordinate_y; if (on_axis) {- double length = fabs (Path.distance (selected_handle.parent.x, coordinate_x,- selected_handle.parent.y, coordinate_y));- - double min = double.MAX;- double circle_edge;- double circle_x;- double circle_y;- - for (double circle_angle = 0; circle_angle < 2 * PI; circle_angle += PI / 4) {- circle_x = selected_handle.parent.x + cos (circle_angle) * length;- circle_y = selected_handle.parent.y + sin (circle_angle) * length;- - circle_edge = fabs (Path.distance (coordinate_x, circle_x, - coordinate_y, circle_y));- - if (circle_edge < min) {- selected_handle.x = circle_x;- selected_handle.y = circle_y;- min = circle_edge;- }- }+ double tied_x = 0;+ double tied_y = 0;+ + PointTool.tie_angle (selected_handle.parent.x, selected_handle.parent.y,+ coordinate_x, coordinate_y, out tied_x, out tied_y);+ + selected_handle.x = tied_x;+ selected_handle.y = tied_y; } } @@ -93,6 +93,36 @@ public class PointTool : Tool { public static Tool pen () { return MainWindow.get_toolbox ().get_tool ("pen_tool"); }+ + public static void tie_angle (double center_x, double center_y,+ double coordinate_x, double coordinate_y, + out double tied_x, out double tied_y) {+ + double length = fabs (Path.distance (center_x, coordinate_x,+ center_y, coordinate_y));+ + tied_x = 0;+ tied_y = 0;+ + double min = double.MAX;+ double circle_edge;+ double circle_x;+ double circle_y;+ + for (double circle_angle = 0; circle_angle < 2 * PI; circle_angle += PI / 4) {+ circle_x = center_x + cos (circle_angle) * length;+ circle_y = center_y + sin (circle_angle) * length;+ + circle_edge = fabs (Path.distance (coordinate_x, circle_x, + coordinate_y, circle_y));+ + if (circle_edge < min) {+ tied_x = circle_x;+ tied_y = circle_y;+ min = circle_edge;+ }+ }+ } } }