Commit 85ccd2f
Fill stroked paths
Changed files (5)
modifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/MoveTool.valamodifiedlibbirdfont/PenTool.valamodifiedlibbirdfont/StrokeTool.valamodifiedlibbirdfont/Theme.vala
Diff
@@ -1523,16 +1523,31 @@ public class Glyph : FontDisplay { public void draw_path (Context cr) { PathList stroke;+ Color color;+ + cr.save ();+ cr.new_path ();+ foreach (Path p in path_list) {+ if (p.stroke > 0) {+ stroke = p.get_stroke_fast ();++ if (p.is_editable () || active_paths.index_of (p) > -1) {+ draw_path_list (stroke, cr); + } else {+ draw_path_list (stroke, cr, Theme.get_color ("Filled Stroke"));+ }+ }+ }+ cr.fill ();+ cr.restore ();+ if (is_open () && Path.fill_open_path) { cr.save (); cr.new_path (); foreach (Path p in path_list) {- if (p.stroke > 0) {- stroke = p.get_stroke_fast ();- draw_path_list (stroke, cr, get_path_fill_color ());+ if (p.stroke == 0) {+ p.draw_path (cr, this, get_path_fill_color ()); }-- p.draw_path (cr, this, get_path_fill_color ()); } cr.fill (); cr.restore ();@@ -1542,11 +1557,6 @@ public class Glyph : FontDisplay { cr.save (); cr.new_path (); foreach (Path p in path_list) {- if (p.stroke > 0) {- stroke = p.get_stroke_fast ();- draw_outline_for_paths (stroke, cr);- }- p.draw_outline (cr); p.draw_edit_points (cr); }@@ -1562,9 +1572,6 @@ public class Glyph : FontDisplay { foreach (Path p in path_list) { if (p.stroke == 0) { p.draw_path (cr, this, Color.black ());- } else {- stroke = p.get_stroke_fast ();- draw_path_list (stroke, cr, Color.black ()); } } cr.close_path ();@@ -1576,8 +1583,6 @@ public class Glyph : FontDisplay { cr.new_path (); if (p.stroke == 0) { p.draw_path (cr, this);- } else {- draw_path_list (p.get_stroke_fast (), cr); } cr.close_path (); cr.fill ();@@ -114,6 +114,7 @@ public class MoveTool : Tool { last_y = y; GlyphCanvas.redraw ();+ PenTool.reset_stroke (); update_selection_boundaries (); @@ -303,6 +304,7 @@ public class MoveTool : Tool { path.move (x * Glyph.ivz (), y * Glyph.ivz ()); } + PenTool.reset_stroke (); update_selection_boundaries (); objects_moved (); glyph.redraw_area (0, 0, glyph.allocation.width, glyph.allocation.height);@@ -420,6 +422,7 @@ public class MoveTool : Tool { } update_selection_boundaries ();+ PenTool.reset_stroke (); BirdFont.get_current_font ().touch (); }@@ -184,6 +184,7 @@ public class PenTool : Tool { point_selection_image = false; BirdFont.get_current_font ().touch ();+ reset_stroke (); }); move_action.connect ((self, x, y) => {@@ -198,6 +199,8 @@ public class PenTool : Tool { }); key_press_action.connect ((self, keyval) => {+ reset_stroke ();+ if (keyval == Key.DEL || keyval == Key.BACK_SPACE) { if (KeyBindings.has_shift ()) { delete_selected_points ();@@ -224,8 +227,6 @@ public class PenTool : Tool { GlyphCanvas.redraw (); BirdFont.get_current_font ().touch ();- - reset_stroke (); }); key_release_action.connect ((self, keyval) => {@@ -551,8 +552,8 @@ public class PenTool : Tool { public static void reset_stroke () { Glyph g = MainWindow.get_current_glyph ();- foreach (Path p in g.active_paths) {- p.reset_stroke ();+ foreach (PointSelection p in selected_points) {+ p.path.reset_stroke (); } } @@ -1910,6 +1911,8 @@ public class PenTool : Tool { } } + reset_stroke ();+ // TODO: redraw only the relevant parts GlyphCanvas.redraw (); }@@ -1701,10 +1701,10 @@ public class StrokeTool : Tool { p1 = path.points.get (0); p2 = path.points.get (1 % path.points.size); - get_segment (thickness, 0, 0.0001, p1, p2, out start);+ get_segment (thickness, 0, 0.00001, p1, p2, out start); side1.add_point (start.copy ()); - get_segment (-thickness, 0, 0.0001, p1, p2, out start);+ get_segment (-thickness, 0, 0.00001, p1, p2, out start); side2.add_point (start.copy ()); } @@ -1713,14 +1713,14 @@ public class StrokeTool : Tool { p2 = path.points.get ((i + 1) % path.points.size); p3 = path.points.get ((i + 2) % path.points.size); - tolerance = 0.13 / sqrt (stroke_width);+ tolerance = 1.3 / sqrt (stroke_width); step_increment = 1.1; step_size = 0.039 / stroke_width; corner1 = new EditPoint (); step = 0;- while (step < 1 - step_size) {+ while (step < 1 - 2 * step_size) { Path.get_point_for_step (p1, p2, step, out x, out y); Path.get_point_for_step (p1, p2, step + step_size, out x2, out y2); Path.get_point_for_step (p1, p2, step + 2 * step_size, out x3, out y3);@@ -1761,8 +1761,8 @@ public class StrokeTool : Tool { step += step_size; } - get_segment (thickness, 1 - step_size, step_size, p1, p2, out corner1);- get_segment (-thickness, 1 - step_size, step_size, p1, p2, out corner1_inside);+ get_segment (thickness, 1 - 0.00001, 0.00001, p1, p2, out corner1);+ get_segment (-thickness, 1 - 0.00001, 0.00001, p1, p2, out corner1_inside); side1.add_point (corner1.copy ()); side2.add_point (corner1_inside.copy ()); previous = corner1;@@ -1773,10 +1773,10 @@ public class StrokeTool : Tool { if (fabs (l.angle + r.angle - PI) % 2 * PI > 0.0001) { if (!path.is_open () || i < size - 1) {- get_segment (thickness, 0, 0.001, p2, p3, out start);+ get_segment (thickness, 0, 0.00001, p2, p3, out start); add_corner (side1, previous, start, p2.copy (), thickness); - get_segment (-thickness, 0, 0.001, p2, p3, out start);+ get_segment (-thickness, 0, 0.00001, p2, p3, out start); add_corner (side2, previous_inside, start, p2.copy (), thickness); } }@@ -99,8 +99,9 @@ public class Theme : GLib.Object { // Bright theme Theme.set_default_color ("Canvas Background", 1, 1, 1, 1);- Theme.set_default_color ("Stroke Color", 0, 0, 0, 1);- Theme.set_default_color ("Handle Color", 0, 0, 0, 1);+ Theme.set_default_color ("Filled Stroke", 0, 0, 0, 1);+ Theme.set_default_color ("Stroke Color", 141 / 255.0, 141 / 255.0, 141 / 255.0, 1);+ Theme.set_default_color ("Handle Color", 141 / 255.0, 141 / 255.0, 141 / 255.0, 1); Theme.set_default_color ("Fill Color", 0.5, 0.5, 0.5, 1); Theme.set_default_color ("Selected Objects", 35 / 255.0, 131 / 255.0, 194 / 255.0, 1); @@ -176,17 +177,17 @@ public class Theme : GLib.Object { Theme.set_default_color ("Dialog Shadow", 0, 0, 0, 0.3); - Theme.set_default_color ("Selected Active Cubic Control Point", 0, 0, 0, 1);- Theme.set_default_color ("Selected Cubic Control Point", 0, 0, 0, 1);+ Theme.set_default_color ("Selected Active Cubic Control Point", 0 / 255.0, 112 / 255.0, 244 / 255.0, 1);+ Theme.set_default_color ("Selected Cubic Control Point", 0 / 255.0, 112 / 255.0, 244 / 255.0, 1); Theme.set_default_color ("Active Cubic Control Point", 70 / 255.0, 70 / 255.0, 70 / 255.0, 1); Theme.set_default_color ("Cubic Control Point", 116 / 255.0, 116 / 255.0, 116 / 255.0, 1); - Theme.set_default_color ("Selected Active Quadratic Control Point", 0, 0, 0, 1);- Theme.set_default_color ("Selected Quadratic Control Point", 0, 0, 0, 1);+ Theme.set_default_color ("Selected Active Quadratic Control Point", 0 / 255.0, 112 / 255.0, 244 / 255.0, 1);+ Theme.set_default_color ("Selected Quadratic Control Point", 0 / 255.0, 112 / 255.0, 244 / 255.0, 1); Theme.set_default_color ("Active Quadratic Control Point", 85 / 255.0, 115 / 255.0, 149 / 255.0, 1); Theme.set_default_color ("Quadratic Control Point", 123 / 255.0, 151 / 255.0, 184 / 255.0, 1); - Theme.set_default_color ("Selected Control Point Handle", 0, 0, 0, 1);+ Theme.set_default_color ("Selected Control Point Handle", 0 / 255.0, 112 / 255.0, 244 / 255.0, 1); Theme.set_default_color ("Active Control Point Handle", 81 / 255.0, 147 / 255.0, 90 / 255.0, 1); Theme.set_default_color ("Control Point Handle", 81 / 255.0, 147 / 255.0, 90 / 255.0, 1); @@ -204,8 +205,9 @@ public class Theme : GLib.Object { // Dark theme Theme.set_default_color ("Canvas Background", 1, 1, 1, 1);- Theme.set_default_color ("Stroke Color", 0, 0, 0, 1);- Theme.set_default_color ("Handle Color", 0, 0, 0, 1);+ Theme.set_default_color ("Filled Stroke", 0, 0, 0, 1);+ Theme.set_default_color ("Stroke Color", 141 / 255.0, 141 / 255.0, 141 / 255.0, 1);+ Theme.set_default_color ("Handle Color", 141 / 255.0, 141 / 255.0, 141 / 255.0, 1); Theme.set_default_color ("Fill Color", 0.5, 0.5, 0.5, 1); Theme.set_default_color ("Selected Objects", 35 / 255.0, 131 / 255.0, 194 / 255.0, 1); @@ -281,17 +283,17 @@ public class Theme : GLib.Object { Theme.set_default_color ("Dialog Shadow", 0, 0, 0, 0.3); - Theme.set_default_color ("Selected Active Cubic Control Point", 0, 0, 0, 1);- Theme.set_default_color ("Selected Cubic Control Point", 0, 0, 0, 1);+ Theme.set_default_color ("Selected Active Cubic Control Point", 234 / 255.0, 77 / 255.0, 26 / 255.0, 1);+ Theme.set_default_color ("Selected Cubic Control Point", 234 / 255.0, 77 / 255.0, 26 / 255.0, 1); Theme.set_default_color ("Active Cubic Control Point", 70 / 255.0, 70 / 255.0, 70 / 255.0, 1); Theme.set_default_color ("Cubic Control Point", 116 / 255.0, 116 / 255.0, 116 / 255.0, 1); - Theme.set_default_color ("Selected Active Quadratic Control Point", 0, 0, 0, 1);- Theme.set_default_color ("Selected Quadratic Control Point", 0, 0, 0, 1);+ Theme.set_default_color ("Selected Active Quadratic Control Point", 234 / 255.0, 77 / 255.0, 26 / 255.0, 1);+ Theme.set_default_color ("Selected Quadratic Control Point", 234 / 255.0, 77 / 255.0, 26 / 255.0, 1); Theme.set_default_color ("Active Quadratic Control Point", 85 / 255.0, 115 / 255.0, 149 / 255.0, 1); Theme.set_default_color ("Quadratic Control Point", 123 / 255.0, 151 / 255.0, 184 / 255.0, 1); - Theme.set_default_color ("Selected Control Point Handle", 0, 0, 0, 1);+ Theme.set_default_color ("Selected Control Point Handle", 234 / 255.0, 77 / 255.0, 26 / 255.0, 1); Theme.set_default_color ("Active Control Point Handle", 81 / 255.0, 147 / 255.0, 90 / 255.0, 1); Theme.set_default_color ("Control Point Handle", 81 / 255.0, 147 / 255.0, 90 / 255.0, 1); @@ -309,8 +311,9 @@ public class Theme : GLib.Object { // High contrast theme Theme.set_default_color ("Canvas Background", 1, 1, 1, 1);- Theme.set_default_color ("Stroke Color", 0, 0, 0, 1);- Theme.set_default_color ("Handle Color", 0, 0, 0, 1);+ Theme.set_default_color ("Filled Stroke", 0, 0, 0, 1);+ Theme.set_default_color ("Stroke Color", 141 / 255.0, 141 / 255.0, 141 / 255.0, 1);+ Theme.set_default_color ("Handle Color", 141 / 255.0, 141 / 255.0, 141 / 255.0, 1); Theme.set_default_color ("Fill Color", 0, 0, 0, 1); Theme.set_default_color ("Selected Objects", 0, 0, 0, 1); @@ -416,6 +419,7 @@ public class Theme : GLib.Object { if (BirdFont.has_argument ("--test")) { t_("Canvas Background");+ t_("Filled Stroke"); t_("Stroke Color"); t_("Handle Color"); t_("Fill Color");