From 46236d9e2533cc57630548b9a701eb0089cd1293 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 2 Apr 2021 10:16:17 +0530 Subject: keybind F cycles brush instead --- src/app.rs | 22 ++++++++++------------ src/utils.rs | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/app.rs b/src/app.rs index 1b192df..16a4433 100644 --- a/src/app.rs +++ b/src/app.rs @@ -147,6 +147,15 @@ impl<'ctx> AppState<'ctx> { } } + pub fn cycle_brush(&mut self) { + self.brush = match self.brush { + Brush::Circle(_) => Brush::line(0, false), + Brush::Line(LineBrush { extend: false, .. }) => Brush::line(0, true), + Brush::Line(LineBrush { extend: true, .. }) => Brush::Fill, + _ => Brush::new(0), + } + } + pub fn paint_point>( &mut self, center: P, @@ -666,19 +675,8 @@ impl<'ctx> AppState<'ctx> { self.pixmap.invert(); self.undo_stack.push(ModifyRecord::Invert); } - // line drawing - Keycode::F => { - if matches!( - self.brush, - Brush::Line(LineBrush { extend: false, .. }) - ) { - self.brush = Brush::line(0, true); - } else { - self.brush = Brush::line(0, false); - } - } + Keycode::F => self.cycle_brush(), // bucket fill tool - Keycode::B => self.brush = Brush::Fill, Keycode::V => self.cycle_symmetry(), // undo & redo 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>( ttf_context: &Sdl2TtfContext, text: S, color: Color, - (x, y): (u32, u32), + (x, y): (i32, i32), ) -> u32 { let text = text.as_ref(); let texture_creator = canvas.texture_creator(); -- cgit v1.2.3