Clone in a terminal:
Commit 2117436
Johan Mattsson - 2014-07-05T12:42:05+00:00
2117436f65a0c9a5b1ff29d0ffeb2e5b9dc4d9b0johan.mattsson.m@gmail.com

Remove dead code

Changed files (7)

Diff

diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex f8c1e96..2783a2c 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -251,17 +251,6 @@ public class DrawingTools : ToolCollection  { 			MainWindow.get_current_glyph ().update_view (); 		}); 		edit_point_modifiers.add_tool (create_line);--		// FIXME: DELETE-		// path tools-		/* -		Tool union_paths_tool = new Tool ("union_paths", t_("Merge paths"));-		union_paths_tool.select_action.connect ((self) => {-			Glyph g = MainWindow.get_current_glyph ();-			g.merge_all ();-		});-		path_tool_modifiers.add_tool (union_paths_tool);-		*/ 	 		Tool reverse_path_tool = new Tool ("reverse_path", t_("Create counter from outline")); 		reverse_path_tool.select_action.connect ((self) => {@@ -347,20 +336,6 @@ public class DrawingTools : ToolCollection  { 		}); 		characterset_tools.add_tool (avalilable_characters); -		/* // FIXME: DELETE-		Tool delete_glyph = new Tool ("delete_selected_glyph", t_("Delete selected glyph"));-		delete_glyph.select_action.connect ((self) => {-			OverView o = MainWindow.get_overview ();-			-			if (MainWindow.get_current_display () is OverView) {-				o.delete_selected_glyph ();-			}-			-			MainWindow.get_tab_bar ().select_tab_name ("Overview");-		});-		characterset_tools.add_tool (delete_glyph);-		*/- 		if (BirdFont.has_argument ("--test")) { 			Tool test_case = new Tool ("test_case"); 			test_case.select_action.connect((self) => {diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 1a84cad..e8e21c7 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -1726,73 +1726,6 @@ public class Glyph : FontDisplay { 		path.insert_new_point_on_path (lep); 	} 	-	/** Merge selected paths. */-	public void merge_all () {-		store_undo_state ();-		-		if (active_paths.size < 2) {-			return;-		}-		-		foreach (Path p0 in active_paths) {-			if (merge_path (p0)) {-				merge_all (); // stop iterating if the list is updated-				break;-			}-		}-		-		close_path ();--		foreach (Path p in path_list) {-			p.update_region_boundaries ();-		}		-		-		redraw_area (0, 0, allocation.width, allocation.height);-	}-	-	public bool merge_path (Path p0) {-		Path mp;-		PathList path_list;-		-		foreach (Path p1 in active_paths) {-			if (p0 == p1) {-				p0 = p1;-				continue;-			}-			-			path_list = Path.merge (p1, p0);--			if (path_list.paths.size == 0) {-				p0 = p1;-				continue;-			}-			-			mp = path_list.get_first_path ();--			delete_path (p0);-			delete_path (p1);-			-			// add new path + its counter paths-			foreach (Path p in path_list.paths) {-				p.close ();			-				add_path (p.copy ());-			}-			-			add_active_path (mp);-			-			active_paths.remove (p0);-			active_paths.remove (p1);--			p0 = mp;-			-			mp.create_list ();-			-			return true;-		}-		-		return false;-	}-	 	static bool in_range (double offset_x, double coordinate_x1, double coordinate_x2) { 		return coordinate_x1 <= offset_x <= coordinate_x2; 	}diff --git a/libbirdfont/Intersection.vala b/libbirdfont/Intersection.valadeleted file mode 100644index c65fba4..0000000--- a/libbirdfont/Intersection.vala+++ /dev/null@@ -1,33 +0,0 @@-/*-    Copyright (C) 2012 Johan Mattsson--    This library is free software; you can redistribute it and/or modify -    it under the terms of the GNU Lesser General Public License as -    published by the Free Software Foundation; either version 3 of the -    License, or (at your option) any later version.--    This library is distributed in the hope that it will be useful, but -    WITHOUT ANY WARRANTY; without even the implied warranty of -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -    Lesser General Public License for more details.-*/--using Math;--namespace BirdFont {--class Intersection {-	public double x;-	public double y;-	public double distance;-	-	public EditPoint editpoint_a;-	public EditPoint editpoint_b;-	-	public Intersection (double x, double y, double distance) {-		this.x = x;-		this.y = y;-	}-}--}diff --git a/libbirdfont/IntersectionList.vala b/libbirdfont/IntersectionList.valadeleted file mode 100644index e892b89..0000000--- a/libbirdfont/IntersectionList.vala+++ /dev/null@@ -1,171 +0,0 @@-/*-    Copyright (C) 2012 Johan Mattsson--    This library is free software; you can redistribute it and/or modify -    it under the terms of the GNU Lesser General Public License as -    published by the Free Software Foundation; either version 3 of the -    License, or (at your option) any later version.--    This library is distributed in the hope that it will be useful, but -    WITHOUT ANY WARRANTY; without even the implied warranty of -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -    Lesser General Public License for more details.-*/--using Math;--namespace BirdFont {--class IntersectionList {-	public List<Intersection> points;-	-	public void add (Intersection i) {-		double d;-		Intersection l;-		bool close = false;-		-		points = new List<Intersection> ();-		-		if (points.length () == 0) {-			points.append (i);-			return;-		}-		-		if (has_point (i)) {-			return;-		}-	-		for (unowned List<Intersection> pl = points.first (); ; pl = pl.next) {-			l = pl.data;-			d = Math.fabs (Math.sqrt (Math.pow (i.x - l.x, 2) + Math.pow (i.y - l.y, 2)));--			if (l.distance >= i.distance) {-				close = true;-				-				if (d < 0.3) {-					points.remove_link (points.last ());-					points.append (i);-					return;-				}-			}-			-			if (pl == points.last ()) {-				break;-			}-		}-		-		if (!close) {-			points.append (i);-		}-	}-		-	public bool has_edit_point (EditPoint e) {-		foreach (Intersection n in points) {-			if (n.editpoint_a == e || n.editpoint_b == e) {-				return true;-			}-		}-		-		return false;-	}-	-	bool has_point (Intersection i) {-		return has_point_at (i.x, i.y);-	}--	bool has_point_at (double x, double y) {-		foreach (Intersection n in points) {-			if (x == n.x && y == n.y) {-				return true;-			}-		}-		-		return false;-	}-	-	public Intersection? get_intersection (EditPoint e) {-		Intersection? p = null;-		foreach (Intersection n in points) {-			if (n.editpoint_a == e || n.editpoint_b == e) {-				assert (p == null);-				p = n;-			}-		}-		return p;-	}-	-	public void append (IntersectionList i) {-		foreach (Intersection inter in i.points) {-			points.append (inter);-		}-	}--	public static IntersectionList create_intersection_list (Path p1, Path p2) {-		IntersectionList il = new IntersectionList ();-		-		unowned EditPoint a_start, a_stop;-		unowned EditPoint b_start, b_stop;-		-		if (p1 == p2) {-			return il;-		}-		-		// find crossing paths-		a_start = p1.points.get (0).get_link_item ();-		for (int i = 0; i < p1.points.size; i++) {-			-			if (a_start.next == null) {-				a_stop = p1.points.get (0).get_link_item ();-			} else {-				a_stop = a_start.get_next ();-			}-			-			b_start = p2.points.get (0).get_link_item ();-			for (int j = 0; j < p2.points.size; j++) {-				-				if (b_start.next == null) {-					b_stop = p2.points.get (0).get_link_item ();-				} else {-					b_stop = b_start.get_next ();-				}--				il.append (find_intersections (a_start, a_stop, b_start, b_stop));--				b_start = b_stop;-			}-			-			a_start = a_stop;-		}-		-		return il;-	}--	static IntersectionList find_intersections (EditPoint a0, EditPoint a1, EditPoint b0, EditPoint b1) {-		IntersectionList il = new IntersectionList ();-		-		double mind = double.MAX; ;-		-		Path.all_of (a0, a1, (ax, ay, at) => {-			if (at == 0 || at == 1) {-				return true;-			}-			-			Path.all_of (b0, b1, (bx, by, bt) => {-				double d = Math.fabs (Math.sqrt (Math.pow (ax - bx, 2) + Math.pow (ay - by, 2)));-				-				if (d < 0.2) {-					il.add (new Intersection (ax, ay, d));-				}-				-				if (d < mind) mind = d;-				return true;-			});-			-			return true;-		});--		return il;-	}-}--}diff --git a/libbirdfont/OverView.vala b/libbirdfont/OverView.valaindex 0db9ade..4dd2aa3 100644--- a/libbirdfont/OverView.vala+++ b/libbirdfont/OverView.vala@@ -618,35 +618,10 @@ public class OverView : FontDisplay { 					key_down (); 				} 				return;-				-			case Key.DEL:-				delete_selected_glyph ();-				return; 		}  		scroll_to_char (keyval); 	}--	public void delete_selected_glyph () {-		Font font = BirdFont.get_current_font ();-		string glyph_name;-		GlyphCollection? glyphs;--		if (all_available) {-			glyphs = font.get_glyph_collection_indice (selected);-		} else {-			glyph_name = glyph_range.get_char (selected);-			glyphs = font.get_glyph_collection (glyph_name);-		}-		-		if (glyphs != null) {-			deleted_glyphs.append ((!) glyphs);-			font.delete_glyph ((!) glyphs);-			MainWindow.get_tab_bar ().close_by_name (((!)glyphs).get_name ());-		}-		-		font.touch ();-	} 	 	public override void undo () { 		Font f = BirdFont.get_current_font ();diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex 472ced3..023bc90 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -492,16 +492,6 @@ public class Path { 		cr.restore (); 	} 	-	/** Returns true if there is an edit point at (p.x, p.y). */-	private bool has_edit_point (EditPoint p) {-		foreach (var t in points) {-			if (p.x == t.x && p.y == t.y) {-				return true;-			}-		}-		return false;-	}-	 	/** Set direction for this path to clockwise for outline and  	 * counter clockwise for inline paths. 	 */@@ -689,11 +679,7 @@ public class Path { 	 	/** Variable precision */ 	public bool is_over_coordinate_var (double x, double y) {-		double last = 0;-		bool on_edge = false;-		double last_x = 0; 		PathList pathlist;-		EditPoint next_e, last_e; 		bool result = false; 		int width; 		char[,] click_map;@@ -1912,291 +1898,8 @@ public class Path { 		foreach (EditPoint p in list) { 			points.add (p); 		}-		-	}-	-	public static PathList merge (Path p0, Path p1) {-		bool done;-		PathList path_list;-		-		done = try_merge (p0.copy(), p1.copy(), out path_list);-		-		if (!done) {-			warning ("failed to merge paths");-		}-		-		return path_list;-	}-	-	private static bool try_merge (Path p0, Path p1, out PathList path_list) {-		EditPoint e;-		IntersectionList il;-		int i;-		Path np;-		Path pi;-		-		il = IntersectionList.create_intersection_list (p0, p1);-		-		path_list = new PathList ();-		-		if (p0 == p1) {-			return false;-		}-		-		// add editpoints on intersections -		p0.update_region_boundaries ();-		p1.update_region_boundaries ();-		foreach (Intersection inter in il.points) {-			e = new EditPoint ();-			p0.get_closest_point_on_path (e, inter.x, inter.y);-			inter.editpoint_a = e;-			-			e = inter.editpoint_a;-			if (!p0.has_edit_point (e)) {-				p0.insert_new_point_on_path (e);-			}--			e = new EditPoint ();-			p1.get_closest_point_on_path (e, inter.x, inter.y);-			inter.editpoint_b = e;-			inter.editpoint_b.x = inter.editpoint_a.x;-			inter.editpoint_b.y = inter.editpoint_a.y;-			-			e = inter.editpoint_b;-			if (!p1.has_edit_point (e)) {-				p1.insert_new_point_on_path (e);-			}-			-			inter.editpoint_a.type = PenTool.to_curve (inter.editpoint_a.get_right_handle ().type);-			inter.editpoint_b.type = PenTool.to_curve (inter.editpoint_b.get_right_handle ().type);-		}-			-		if (il.points.length () < 2) {-			return false;-		}-		-		//path_list.paths.append (p0);-		//path_list.paths.append (p1);-		//return false;-		-		// get all parts-		foreach (Intersection inter in il.points) {-			p0.set_new_start (inter.editpoint_a);-			get_merge_part (il, p0, p1, out np);-			path_list.add (np);-		}-		-		foreach (Path pp in path_list.paths) {-			pp.update_region_boundaries ();-		}--		// remove duplicate paths-		for (i = 0; i < path_list.paths.size; i++) {-			pi = path_list.paths.get (i);--			if (is_duplicated (path_list, pi)) {-				path_list.paths.remove (pi);-				--i;			-			}-		}-		-		// remove paths contained in other paths-		for (i = 0; i < path_list.paths.size; i++) {-			pi = path_list.paths.get (i);-			-			if (pi.is_clockwise () && is_clasped (path_list, pi)) {-				path_list.paths.remove (pi);-				i--;-			}-		}-	-		return true;-	}-	-	private static bool is_duplicated (PathList pl, Path p) {-		bool duplicate = false;-		foreach (Path pd in pl.paths) {-			if (pd == p) {-				continue;-			}-			-			if (is_duplicated_path (p, pd)) {-				duplicate = true;-			}-		}-		-		return duplicate;-	}-	-	private static bool is_duplicated_path (Path p0, Path p1) {-		bool eq;-		-		assert (p1 != p0);	-		-		foreach (EditPoint ep in p0.points) {-			eq = false;-			-			foreach (EditPoint e in p1.points) {-				eq = (Math.fabs (ep.x - e.x) < 0.04 && Math.fabs (ep.y - e.y) < 0.04);-				-				if (eq) {-					break;-				}-			}-			-			if (eq) {-				continue;-			} else {-				return false;-			}-		}-		-		return true;-	}-	-	public static bool is_clasped (PathList pl, Path p) {-		foreach (Path o in pl.paths) {-			if (o == p) {-				continue;-			}-			-			if (is_clasped_path (o, p)) {-				return true;-			}-		}-		-		return false;-	}--	private static bool is_clasped_path (Path outside, Path inside) {-		bool i = true;-		foreach (EditPoint e in inside.points) {-			if (!outside.is_over_coordinate_var (e.x, e.y)) { // point may be off curve in both paths-				i = false;-				break;-			}-		}-		return i; 	} 	-	private static bool get_merge_part (IntersectionList il, Path p0, Path p1, out Path new_path) {-		EditPoint ex;-		EditPoint ix;-		EditPoint en;-		uint offset_i = 0;-		uint offset_j;-		uint len_i;-		int i, j;-		uint len_j;-		Path np = new Path ();-		Intersection s = new Intersection (0, 0, 1);-		-		ex = p0.points.get (p0.points.size - 1);-		ix = p0.points.get (p0.points.size - 1);-		len_i = p0.points.size;-		-		for (i = 0; i < p0.points.size; i++) {-			ex = p0.points.get ((int) ((i + offset_i) % len_i));--			if (ex == p0.points.get (0) && i != 0) {	-				s = (!) il.get_intersection (ex);	-				break;-			}--			// add new point for path a-			if (np.has_edit_point (ex)) {-				// SPLIT-				warning ("Merged path need split");-				np.close ();-				new_path = np;-				-				return false;-			} else {-				en = ex.copy ();-				np.add_point (en);-				en.recalculate_linear_handles ();-			}-			-			// swap paths-			if (il.has_edit_point (ex)) {-				s = (!) il.get_intersection (ex);-			-				en.type = PointType.CUBIC;-				en.right_handle.type = PointType.CUBIC;-				en.right_handle.angle  = s.editpoint_b.right_handle.angle;-				en.right_handle.length = s.editpoint_b.right_handle.length;-							-				// read until we find ex-				for (j = 0; j < p1.points.size; j++) {-					ix = p1.points.get (j);-					-					if (ix == s.editpoint_b) {-						break;-					}-				}-				-				offset_j = j + 1;-				len_j = p1.points.size;-				for (j = 0; j < p1.points.size; j++) {-					-					ix = p1.points.get ((int) ((j + offset_j) % len_j));-					-					// add-					if (np.has_edit_point (ix)) {-						// SPLIT-						warning ("Merged path need split");-						np.close ();-						new_path = np;-						-						break;-					} else {-						en = ix.copy ();-						np.add_point (en);-						ix.recalculate_linear_handles ();-					}-					-					if (il.has_edit_point (ix)) {-						s = (!) il.get_intersection (ix);-						break;-					}-				}--				en.type = PointType.CUBIC;-				en.right_handle.type = PointType.CUBIC;-				en.right_handle.angle  = s.editpoint_a.right_handle.angle;-				en.right_handle.length = s.editpoint_a.right_handle.length;-								-				if (j == p0.points.size) {-					np.close ();-					new_path = np;-					return true;-				}--				// skip to next intersection-				int k;-				for (k = 0; k < p0.points.size; k++) {-					ix = p0.points.get (k); --					if (ix == s.editpoint_a) {-						break;-					}-				}-				-				if (k == p0.points.size) {-					new_path = np;-					return true;-				}-				-				offset_i = 0;-				i = k;-			}-		}--		new_path = np;-		-		return true;	-	}- 	public void append_path (Path path) { 		if (points.size == 0 || path.points.size == 0) { 			warning ("No points");@@ -2420,6 +2123,31 @@ public class Path { 			insert_new_point_on_path (ep); 		} 	}+	+	public static bool is_clasped (PathList pl, Path p) {+		foreach (Path o in pl.paths) {+			if (o == p) {+				continue;+			}+			+			if (is_clasped_path (o, p)) {+				return true;+			}+		}+		+		return false;+	}++	private static bool is_clasped_path (Path outside, Path inside) {+		bool i = true;+		foreach (EditPoint e in inside.points) {+			if (!outside.is_over_coordinate_var (e.x, e.y)) { // point may be off curve in both paths+				i = false;+				break;+			}+		}+		return i;+	} }  }diff --git a/libbirdfont/TestCases.vala b/libbirdfont/TestCases.valaindex 210da9d..d8b4b43 100644--- a/libbirdfont/TestCases.vala+++ b/libbirdfont/TestCases.vala@@ -32,7 +32,6 @@ class TestCases { 		add (test_delete_points, "Delete edit points"); 		add (test_convert_to_quadratic_bezier_path, "Convert to quadratic path"); 		add (test_notdef, "Notdef");-		add (test_merge, "Merge"); 		add (test_over_path, "Over path"); 		add (test_export, "Export"); 		add (test_background_coordinates, "Background coordinates");@@ -628,41 +627,6 @@ class TestCases { 		 	} -	public static void test_merge () {-		Glyph g;-		Path p = new Path ();-		Path p2 = new Path ();-		-		test_open_next_glyph ();-		g = MainWindow.get_current_glyph ();-				-		p.add (-10, 10);-		p.add (10, 10);-		p.add (10, -10);-		p.add (-10, -10);-		p.close ();-		g.add_path (p);--		p2.add (10, 10);-		p2.add (10, -10);		-		p2.add (20, -10);-		p2.add (20, 10);-		p2.reverse ();-		p2.close ();-		g.add_path (p2);-		-		g.add_active_path (p);-		g.add_active_path (p);-		-		g.add_active_path (p);-		g.merge_all	();-		-		test_merge_second_triangle ();-		test_merge_simple_path_box_and_triangle ();-		test_merge_simple_path_box ();-		test_merge_odd_paths ();-	}- 	public static void test_notdef () { 		Font f = BirdFont.get_current_font (); 		Glyph n = f.get_not_def_character ();@@ -1285,231 +1249,6 @@ class TestCases { 		o.open_current_glyph (); 		Tool.yield (); 	}--	private static  void test_merge_odd_paths () {-		Tool pen_tool = MainWindow.get_toolbox ().get_tool ("pen_tool");--		Tool.yield ();-		MainWindow.get_tab_bar ().select_overview ();--		Tool.yield ();-		MainWindow.get_overview ().open_current_glyph ();-		-		test_select_action (pen_tool);--		// paint-		int x_offset = 100;-		int y_offset = 100;-						-		// rectangle-		test_click_action (pen_tool, 1, 100 + x_offset, 100 + y_offset);-		test_click_action (pen_tool, 1, 170 + x_offset, 100 + y_offset);-		test_click_action (pen_tool, 1, 170 + x_offset, 120 + y_offset);-		test_click_action (pen_tool, 1, 100 + x_offset, 120 + y_offset); -		test_click_action (pen_tool, 3, 0, 0); // close-		-		// triangle-		test_click_action (pen_tool, 1, 100 + x_offset, 110 + y_offset);-		test_click_action (pen_tool, 1, 180 + x_offset, 130 + y_offset);-		test_click_action (pen_tool, 1, -10 + x_offset, 140 + y_offset);-		test_click_action (pen_tool, 3, 0, 0);--		// several triangles-		test_click_action (pen_tool, 1, 198, 379); -		test_click_action (pen_tool, 1, 274, 328); -		test_click_action (pen_tool, 1, 203, 286); -		test_click_action (pen_tool, 3, 230, 333);--		test_click_action (pen_tool, 1, 233, 429); -		test_click_action (pen_tool, 1, 293, 382); -		test_click_action (pen_tool, 1, 222, 322); -		test_click_action (pen_tool, 3, 225, 406);--		test_click_action (pen_tool, 1, 164, 316); -		test_click_action (pen_tool, 1, 262, 289); -		test_click_action (pen_tool, 1, 203, 260); -		test_click_action (pen_tool, 3, 203, 260); --		Tool.yield ();-		-		Toolbox.select_tool_by_name ("merge");-	}	-	-	private static void test_merge_simple_path_box () {-		Tool pen_tool = MainWindow.get_toolbox ().get_tool ("pen_tool");--		Tool.yield ();-		MainWindow.get_tab_bar ().select_overview ();--		Tool.yield ();-		MainWindow.get_overview ().open_current_glyph ();-		-		test_select_action (pen_tool);--		int x_offset = 10;-		int y_offset = 350;-		-		// draw it-		test_click_action (pen_tool, 1, 10 + x_offset, 10 + y_offset);-		test_click_action (pen_tool, 1, 20 + x_offset, 10 + y_offset);-		test_click_action (pen_tool, 1, 20 + x_offset, 20 + y_offset);-		test_click_action (pen_tool, 1, 10 + x_offset, 20 + y_offset); -		test_click_action (pen_tool, 3, 0, 0);--		test_press_action (pen_tool, 1, 1, 1);-		test_move_action (pen_tool, 15 + x_offset, 15 + y_offset);-		test_release_action (pen_tool, 1, 15 + x_offset, 15 + y_offset);-				-		test_click_action (pen_tool, 1, 25 + x_offset, 15 + y_offset);-		test_click_action (pen_tool, 1, 25 + x_offset, 25 + y_offset);-		test_click_action (pen_tool, 1, 15 + x_offset, 25 + y_offset); -		test_click_action (pen_tool, 3, 0, 0);-		-		// merge it-		Toolbox.select_tool_by_name ("union_paths");-		-		// test result-		Path merged_outline = new Path ();-		add_point_on_path (merged_outline, 10 + x_offset, 10 + y_offset);-		add_point_on_path (merged_outline, 20 + x_offset, 10 + y_offset);-		add_point_on_path (merged_outline, 20 + x_offset, 15 + y_offset);-		add_point_on_path (merged_outline, 25 + x_offset, 15 + y_offset);-		add_point_on_path (merged_outline, 25 + x_offset, 25 + y_offset);-		add_point_on_path (merged_outline, 15 + x_offset, 25 + y_offset);-		add_point_on_path (merged_outline, 15 + x_offset, 20 + y_offset);-		add_point_on_path (merged_outline, 10 + x_offset, 20 + y_offset);-		merged_outline.close ();-		-		// select path-		test_click_action (pen_tool, 3, 12 + x_offset, 12 + y_offset);-		-		Glyph g = MainWindow.get_current_glyph ();-		Path? l = g.get_active_path ();-		-		if (l == null) {-			critical ("No path found in merge test, it did not merge correctly.");-			return;-		}-		-		Path last = (!) l;-		bool merged_path_looks_good = false;-		 merged_path_looks_good = last.test_is_outline (merged_outline);-		-		if (!merged_path_looks_good) critical ("Failed to merge path correctly.");-	}--	private static void test_merge_simple_path_box_and_triangle () {-		Tool pen_tool = MainWindow.get_toolbox ().get_tool ("pen_tool");--		Tool.yield ();-		MainWindow.get_tab_bar ().select_overview ();--		Tool.yield ();-		MainWindow.get_overview ().open_current_glyph ();-		-		test_select_action (pen_tool);--		int x_offset = 40;-		int y_offset = 350;-		-		// draw it-		test_click_action (pen_tool, 1, 0 + x_offset, -50 + y_offset);-		test_click_action (pen_tool, 1, 25 + x_offset, -50 + y_offset);-		test_click_action (pen_tool, 1, 25 + x_offset, 0 + y_offset);-		test_click_action (pen_tool, 1, 0 + x_offset, 0 + y_offset); -		test_click_action (pen_tool, 3, 0, 0);-		-		test_click_action (pen_tool, 1, 0 + x_offset, 0 + y_offset);-		test_click_action (pen_tool, 1, 50 + x_offset, -50 + y_offset);-		test_click_action (pen_tool, 1, 50 + x_offset, 0 + y_offset); -		test_click_action (pen_tool, 3, 0, 0);--		// merge it-		Toolbox.select_tool_by_name ("union_paths");-		-		// test result-		Path merged_outline = new Path ();-		add_point_on_path (merged_outline, 0 + x_offset, -50 + y_offset);-		add_point_on_path (merged_outline, 25 + x_offset, -50 + y_offset);-		add_point_on_path (merged_outline, -50 + x_offset, -50 + y_offset);-		add_point_on_path (merged_outline, -50 + x_offset, 0 + y_offset);-		add_point_on_path (merged_outline, 0 + x_offset, 0 + y_offset);-		merged_outline.close ();--		// select path-		test_click_action (pen_tool, 3, 21 + x_offset, -11 + y_offset);-		-		Glyph g = MainWindow.get_current_glyph ();-		Path? l = g.get_active_path ();-		-		if (l == null) {-			critical ("No path found in test_merge_simple_path_box_and_triangle, it did not merge correctly.");-			return;-		}-		-		Path last = (!) l;-		bool merged_path_looks_good = false;-		 merged_path_looks_good = last.test_is_outline (merged_outline);-		-		if (!merged_path_looks_good) critical ("Failed to merge path correctly.");-	}--	private static void test_merge_second_triangle () {-		Tool pen_tool = MainWindow.get_toolbox ().get_tool ("pen_tool");--		Tool.yield ();-		MainWindow.get_tab_bar ().select_overview ();--		Tool.yield ();-		MainWindow.get_overview ().open_current_glyph ();-		-		test_select_action (pen_tool);--		int x_offset = 100;-		int y_offset = 350;-		-		// draw it-		test_click_action (pen_tool, 1, 25 + x_offset, 0 + y_offset);-		test_click_action (pen_tool, 1, 25 + x_offset, -50 + y_offset);-		test_click_action (pen_tool, 1, 0 + x_offset, -50 + y_offset);-		test_click_action (pen_tool, 1, 0 + x_offset, 0 + y_offset); --		test_click_action (pen_tool, 3, 0, 0);-		-		test_click_action (pen_tool, 1, 40 + x_offset, -50 + y_offset);-		test_click_action (pen_tool, 1, 10 + x_offset, -20 + y_offset);-		test_click_action (pen_tool, 1, 25 + x_offset, -20 + y_offset); -		test_click_action (pen_tool, 3, 0, 0);-		-		// merge it-		Toolbox.select_tool_by_name ("union_paths");-		-		// test result-		Path merged_outline = new Path ();-		add_point_on_path (merged_outline, 0 + x_offset, -50 + y_offset);-		add_point_on_path (merged_outline, 25 + x_offset, -50 + y_offset);-		add_point_on_path (merged_outline, -50 + x_offset, -50 + y_offset);-		add_point_on_path (merged_outline, -50 + x_offset, 0 + y_offset);-		add_point_on_path (merged_outline, 0 + x_offset, 0 + y_offset);-		merged_outline.close ();--		// select path-		test_click_action (pen_tool, 3, 21 + x_offset, -11 + y_offset);-		-		Glyph g = MainWindow.get_current_glyph ();-		Path? l = g.get_active_path ();-		-		if (l == null) {-			critical ("No path found in triangle_right, it did not merge correctly.");-			return;-		}-		-		Path last = (!) l;-		bool merged_path_looks_good = false;-		 merged_path_looks_good = last.test_is_outline (merged_outline);-		-		if (!merged_path_looks_good) critical ("Failed to merge path correctly.");-	} 	 	private static void add_point_on_path (Path p, int x, int y) { 		p.add (Glyph.path_coordinate_x (x), Glyph.path_coordinate_y (y));

Contact

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