Clone in a terminal:
Commit 7e1ea2d
Johan Mattsson - 2015-08-25T12:28:26+00:00
7e1ea2db2242e99bf263b646469a8e86f82b7977johan.mattsson.m@gmail.com

Use global settings for autotrace

Changed files (3)

Diff

diff --git a/birdfont-autotrace/AutoTrace.vala b/birdfont-autotrace/AutoTrace.valaindex c872202..a5e442f 100644--- a/birdfont-autotrace/AutoTrace.vala+++ b/birdfont-autotrace/AutoTrace.vala@@ -116,9 +116,9 @@ class AutoTrace { 			font = BirdFont.new_font (); 			bg = new BackgroundImage (f); 			-			bg.set_trace_resolution (details);-			bg.set_threshold (cutoff);-			bg.set_trace_simplification (simplification);+			DrawingTools.auto_trace_resolution.set_value_round (details);+			DrawingTools.background_threshold.set_value_round (details);+			DrawingTools.auto_trace_simplify.set_value_round (simplification); 			bg.set_high_contrast (true);  			g = new Glyph.no_lines ("");diff --git a/libbirdfont/BackgroundImage.vala b/libbirdfont/BackgroundImage.valaindex 119c228..b1ff2a0 100644--- a/libbirdfont/BackgroundImage.vala+++ b/libbirdfont/BackgroundImage.vala@@ -42,9 +42,6 @@ public class BackgroundImage { 	private string path;  	public bool high_contrast = false;-	private double trace_resolution = 1.0;-	private double threshold = 1.0;-	private double simplification = 0.5; 	private Gee.ArrayList<TracedPoint> points = new Gee.ArrayList<TracedPoint> (); 	private Gee.ArrayList<TracedPoint> start_points = new Gee.ArrayList<TracedPoint> (); 	@@ -108,10 +105,7 @@ public class BackgroundImage { 		bg.img_scale_y = img_scale_y; 		bg.img_rotation = img_rotation; -		bg.simplification = simplification;-		bg.threshold = threshold; 		bg.high_contrast = high_contrast;-		bg.trace_resolution = trace_resolution; 		 		foreach (BackgroundSelection b in selections) { 			bg.selections.add (b);@@ -124,18 +118,10 @@ public class BackgroundImage { 		selections.add (bs); 	} -	public void set_trace_simplification (double s) {-		simplification = s;-	}- 	public void set_high_contrast (bool t) { 		high_contrast = t; 	} -	public void set_trace_resolution (double t) {-		trace_resolution = t;-	}- 	public double get_margin_width () { 		return ((size_margin - get_img ().get_width ()) / 2.0); 	}@@ -684,10 +670,6 @@ public class BackgroundImage { 		updated (); 	} -	public void set_threshold (double t) {-		threshold = t;-	}- 	ImageSurface get_contrast_image () { 		ImageSurface s; 		Context c;@@ -702,6 +684,10 @@ public class BackgroundImage { 		 		ImageSurface img; 		ImageSurface ns;++		double trace_resolution = DrawingTools.auto_trace_resolution.get_value ();+		double threshold = DrawingTools.background_threshold.get_value ();+		double simplification = DrawingTools.auto_trace_simplify.get_value (); 		 		thres = (threshold - 0.5) * 255; 		@@ -1174,6 +1160,7 @@ public class BackgroundImage { 		TracedPoint average_point; 		int pi; 		ImageSurface img;+		double simplification = DrawingTools.auto_trace_simplify.get_value ();  		img = (contrast_image == null) ? get_contrast_image () : (!) contrast_image; diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex 3a26634..8012123 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -64,12 +64,12 @@ public class DrawingTools : ToolCollection  { 	public static CutBackgroundTool cut_background; 	Tool show_bg; 	Tool bg_selection;-	SpinButton background_threshold;+	public static SpinButton background_threshold; 	public static SpinButton background_scale; 	Tool high_contrast_background;-	SpinButton auto_trace_resolution;+	public static SpinButton auto_trace_resolution; 	Tool auto_trace;-	SpinButton auto_trace_simplify;+	public static SpinButton auto_trace_simplify; 	Tool delete_background;  	Tool rectangle;@@ -733,7 +733,6 @@ public class DrawingTools : ToolCollection  { 			 			if (bg != null) { 				b = (!) bg;-				b.set_threshold (background_threshold.get_value ()); 				b.update_background (); 			} 		});@@ -751,7 +750,6 @@ public class DrawingTools : ToolCollection  { 			 			if (bg != null) { 				b = (!) bg;-				b.set_trace_resolution (auto_trace_resolution.get_value ()); 				b.update_background (); 			} 		});@@ -763,14 +761,6 @@ public class DrawingTools : ToolCollection  { 		auto_trace_simplify.show_icon (true);  		auto_trace_simplify.new_value_action.connect ((self) => {-			Glyph g = MainWindow.get_current_glyph ();-			BackgroundImage? bg = g.get_background_image ();-			BackgroundImage b;-			-			if (bg != null) {-				b = (!) bg;-				b.set_trace_simplification (auto_trace_simplify.get_value ());-			} 		}); 		 		draw_tool_modifiers.add_tool (auto_trace_simplify);

Contact

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