Clone in a terminal:
Commit fa3ffb3
Johan Mattsson - 2016-05-15T13:02:10+00:00
fa3ffb3087cbaffd08ff802d31218a08e404c6e9johan.mattsson.m@gmail.com

Merge ../birdfont-2.x

Changed files (3)

Diff

diff --git a/libbirdfont/BezierTool.vala b/libbirdfont/BezierTool.valaindex de411f5..fd3b379 100644--- a/libbirdfont/BezierTool.vala+++ b/libbirdfont/BezierTool.vala@@ -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 (); 		} 		diff --git a/libbirdfont/PenTool.vala b/libbirdfont/PenTool.valaindex 8e11901..15b424e 100644--- a/libbirdfont/PenTool.vala+++ b/libbirdfont/PenTool.vala@@ -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; 				} 			} diff --git a/libbirdfont/PointTool.vala b/libbirdfont/PointTool.valaindex 83e4658..0cf7b38 100644--- a/libbirdfont/PointTool.vala+++ b/libbirdfont/PointTool.vala@@ -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;+			}+		}+	} }  }

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112