The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Use global settings for autotrace

These changes was commited to the Birdfont repository Tue, 25 Aug 2015 12:28:26 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Tue, 25 Aug 2015 12:28:26 +0000]

Updated Files

birdfont-autotrace/AutoTrace.vala
libbirdfont/BackgroundImage.vala
libbirdfont/DrawingTools.vala
--- a/birdfont-autotrace/AutoTrace.vala +++ b/birdfont-autotrace/AutoTrace.vala @@ -116,9 +116,9 @@ 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 ("");
--- a/libbirdfont/BackgroundImage.vala +++ b/libbirdfont/BackgroundImage.vala @@ -42,9 +42,6 @@ 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 @@ 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); @@ -122,18 +116,10 @@ public void add_selection (BackgroundSelection bs) { 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 () { @@ -682,10 +668,6 @@ GlyphCanvas.redraw (); updated (); - } - - public void set_threshold (double t) { - threshold = t; } ImageSurface get_contrast_image () { @@ -702,6 +684,10 @@ 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 @@ TracedPoint average_point; int pi; ImageSurface img; + double simplification = DrawingTools.auto_trace_simplify.get_value (); img = (contrast_image == null) ? get_contrast_image () : (!) contrast_image;
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -64,12 +64,12 @@ 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 @@ if (bg != null) { b = (!) bg; - b.set_threshold (background_threshold.get_value ()); b.update_background (); } }); @@ -751,7 +750,6 @@ if (bg != null) { b = (!) bg; - b.set_trace_resolution (auto_trace_resolution.get_value ()); b.update_background (); } }); @@ -763,14 +761,6 @@ 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);