diff options
-rw-r--r-- | src/app.rs | 22 | ||||
-rw-r--r-- | src/utils.rs | 2 |
2 files changed, 11 insertions, 13 deletions
@@ -147,6 +147,15 @@ impl<'ctx> AppState<'ctx> { | |||
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | pub fn cycle_brush(&mut self) { | ||
151 | self.brush = match self.brush { | ||
152 | Brush::Circle(_) => Brush::line(0, false), | ||
153 | Brush::Line(LineBrush { extend: false, .. }) => Brush::line(0, true), | ||
154 | Brush::Line(LineBrush { extend: true, .. }) => Brush::Fill, | ||
155 | _ => Brush::new(0), | ||
156 | } | ||
157 | } | ||
158 | |||
150 | pub fn paint_point<P: Into<Point>>( | 159 | pub fn paint_point<P: Into<Point>>( |
151 | &mut self, | 160 | &mut self, |
152 | center: P, | 161 | center: P, |
@@ -666,19 +675,8 @@ impl<'ctx> AppState<'ctx> { | |||
666 | self.pixmap.invert(); | 675 | self.pixmap.invert(); |
667 | self.undo_stack.push(ModifyRecord::Invert); | 676 | self.undo_stack.push(ModifyRecord::Invert); |
668 | } | 677 | } |
669 | // line drawing | 678 | Keycode::F => self.cycle_brush(), |
670 | Keycode::F => { | ||
671 | if matches!( | ||
672 | self.brush, | ||
673 | Brush::Line(LineBrush { extend: false, .. }) | ||
674 | ) { | ||
675 | self.brush = Brush::line(0, true); | ||
676 | } else { | ||
677 | self.brush = Brush::line(0, false); | ||
678 | } | ||
679 | } | ||
680 | // bucket fill tool | 679 | // bucket fill tool |
681 | Keycode::B => self.brush = Brush::Fill, | ||
682 | Keycode::V => self.cycle_symmetry(), | 680 | Keycode::V => self.cycle_symmetry(), |
683 | // undo & redo | 681 | // undo & redo |
684 | Keycode::U => { | 682 | Keycode::U => { |
diff --git a/src/utils.rs b/src/utils.rs index 9859f39..6819e71 100644 --- a/src/utils.rs +++ b/src/utils.rs | |||
@@ -38,7 +38,7 @@ pub fn draw_text<S: AsRef<str>>( | |||
38 | ttf_context: &Sdl2TtfContext, | 38 | ttf_context: &Sdl2TtfContext, |
39 | text: S, | 39 | text: S, |
40 | color: Color, | 40 | color: Color, |
41 | (x, y): (u32, u32), | 41 | (x, y): (i32, i32), |
42 | ) -> u32 { | 42 | ) -> u32 { |
43 | let text = text.as_ref(); | 43 | let text = text.as_ref(); |
44 | let texture_creator = canvas.texture_creator(); | 44 | let texture_creator = canvas.texture_creator(); |