Commit d1688c8
Set minimum stroke with to 0.02
Changed files (8)
modifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/DrawingTools.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/Path.valamodifiedlibbirdfont/PenTool.valamodifiedlibbirdfont/StrokeTool.valamodifiedlibbirdfont/Svg.valamodifiedlibbirdfont/TestCases.vala
Diff
@@ -1400,7 +1400,7 @@ class BirdFontFile : GLib.Object { foreach (Attribute attr in tag.get_attributes ()) { if (attr.get_name () == "stroke") {- path.set_stroke (double.parse (attr.get_content ()));+ path.stroke = double.parse (attr.get_content ()); } if (attr.get_name () == "skew") {@@ -806,6 +806,7 @@ public class DrawingTools : ToolCollection { // add stroke to path add_stroke = new Tool ("apply_stroke", t_("Apply stroke"));+ add_stroke.select_action.connect ((self) => { Font f; Glyph g = MainWindow.get_current_glyph ();@@ -856,7 +857,7 @@ public class DrawingTools : ToolCollection { || bezier_tool.is_selected (); StrokeTool.stroke_width = object_stroke.get_value ();- + if (tool && StrokeTool.add_stroke) { foreach (Path p in g.active_paths) { p.stroke = StrokeTool.stroke_width;@@ -214,7 +214,7 @@ public class Glyph : FontDisplay { foreach (Path p in get_visible_paths ()) { if (p.stroke > 0) {- stroke = p.get_stroke ();+ stroke = p.get_completed_stroke (); foreach (Path stroke_part in stroke.paths) { pc = new PointConverter (stroke_part); pl.add (pc.get_quadratic_path ());@@ -51,7 +51,22 @@ public class Path : GLib.Object { public double ymin = Glyph.CANVAS_MAX; /** Stroke width */- public double stroke = 0;+ public double stroke {+ get {+ return path_stroke_width;+ }+ + set {+ if (0 < value < 0.1) {+ path_stroke_width = 0.2;+ } else {+ path_stroke_width = value;+ }+ }+ }+ + private double path_stroke_width = 0;+ public LineCap line_cap = LineCap.BUTT; public PathList? full_stroke = null; PathList? fast_stroke = null;@@ -158,10 +173,6 @@ public class Path : GLib.Object { return points.size == 0; } - public void set_stroke (double width) {- stroke = width; - }- public void draw_boundaries (Context cr) { double x = Glyph.reverse_path_coordinate_x (xmin); double y = Glyph.reverse_path_coordinate_y (ymin);@@ -2456,7 +2467,7 @@ public class Path : GLib.Object { } } - public PathList get_stroke () {+ public PathList get_completed_stroke () { if (full_stroke == null) { StrokeTool s = new StrokeTool (); full_stroke = s.get_stroke (this, stroke);@@ -1846,7 +1846,7 @@ public class PenTool : Tool { np.add (xt, yt); if (DrawingTools.pen_tool.is_selected ()) {- np.set_stroke (PenTool.path_stroke_width);+ np.stroke = PenTool.path_stroke_width; } PenTool.active_path = np;@@ -53,7 +53,7 @@ public class StrokeTool : GLib.Object { foreach (Path p in g.active_paths) { if (p.stroke > 0) {- paths.append (p.get_stroke ());+ paths.append (p.get_completed_stroke ()); } } @@ -138,7 +138,7 @@ public class StrokeTool : GLib.Object { if (p.stroke == 0) { o.add (p); } else {- o.append (p.get_stroke ());+ o.append (p.get_completed_stroke ()); } } @@ -27,7 +27,7 @@ public class Svg { if (p.stroke == 0) { write_path_as_glyph (p, svg, g); } else {- stroke_list = p.get_stroke ();+ stroke_list = p.get_completed_stroke (); write_paths_as_glyph (stroke_list, svg, g); } }@@ -173,7 +173,7 @@ class TestCases { glyph = MainWindow.get_current_glyph (); for (int i = 0; i < 5; i++) { foreach (Path p in glyph.get_all_paths ()) {- p.set_stroke (i / 100.0);+ p.stroke = (i / 100.0); glyph.update_view (); Tool.yield (); }