aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app.rs44
-rw-r--r--src/bitmap.rs8
-rw-r--r--src/lisp/error.rs1
3 files changed, 33 insertions, 20 deletions
diff --git a/src/app.rs b/src/app.rs
index 063f54f..f6e2b96 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -30,28 +30,30 @@ pub enum Mode {
30} 30}
31 31
32pub struct AppState<'ctx> { 32pub struct AppState<'ctx> {
33 active_color: bool, 33 pub active_color: bool,
34 brush_size: u8, 34 pub brush_size: u8,
35 canvas: Canvas<Window>, 35 pub canvas: Canvas<Window>,
36 context: &'ctx Sdl, 36 pub command_box: CommandBox,
37 current_operation: Operation, 37 pub context: &'ctx Sdl,
38 dither_level: u8, 38 pub current_operation: Operation,
39 grid: Grid, 39 pub dither_level: u8,
40 last_point: Option<MapPoint>, 40 pub grid: Grid,
41 mode: Mode, 41 pub last_point: Option<MapPoint>,
42 mouse: (i32, i32), 42 pub lisp_env: Environment,
43 pixmap: Pixmap<bool>, 43 pub message: Message,
44 start: Point, 44 pub mode: Mode,
45 symmetry: Symmetry, 45 pub mouse: (i32, i32),
46 ttf_context: &'ctx Sdl2TtfContext, 46 pub pixmap: Pixmap<bool>,
47 undo_stack: UndoStack<Operation>, 47 pub start: Point,
48 command_box: CommandBox, 48 pub symmetry: Symmetry,
49 zoom: u8, 49 pub ttf_context: &'ctx Sdl2TtfContext,
50 pub undo_stack: UndoStack<Operation>,
51 pub zoom: u8,
50} 52}
51 53
52struct Grid { 54pub struct Grid {
53 enabled: bool, 55 pub enabled: bool,
54 color: Color, 56 pub color: Color,
55} 57}
56 58
57impl Grid { 59impl Grid {
@@ -563,6 +565,8 @@ impl<'ctx> AppState<'ctx> {
563 Keycode::X => self.change_active_color(), 565 Keycode::X => self.change_active_color(),
564 // toggle grid 566 // toggle grid
565 Keycode::Tab => self.toggle_grid(), 567 Keycode::Tab => self.toggle_grid(),
568 // invert canvas
569 Keycode::I => self.pixmap.invert(),
566 // line drawing 570 // line drawing
567 Keycode::F => { 571 Keycode::F => {
568 let end: Point = (mouse.x(), mouse.y()).into(); 572 let end: Point = (mouse.x(), mouse.y()).into();
diff --git a/src/bitmap.rs b/src/bitmap.rs
index d02cafb..c7e8fd4 100644
--- a/src/bitmap.rs
+++ b/src/bitmap.rs
@@ -231,6 +231,14 @@ where
231 } 231 }
232} 232}
233 233
234impl Pixmap<bool> {
235 pub fn invert(&mut self) {
236 for px in self.data.iter_mut() {
237 *px = !(*px);
238 }
239 }
240}
241
234fn abs_difference<T: Sub<Output = T> + Ord>(x: T, y: T) -> T { 242fn abs_difference<T: Sub<Output = T> + Ord>(x: T, y: T) -> T {
235 if x < y { 243 if x < y {
236 y - x 244 y - x
diff --git a/src/lisp/error.rs b/src/lisp/error.rs
index b789f7f..7214753 100644
--- a/src/lisp/error.rs
+++ b/src/lisp/error.rs
@@ -3,4 +3,5 @@ use crate::lisp::lex::Span;
3#[derive(Debug, PartialEq, Copy, Clone)] 3#[derive(Debug, PartialEq, Copy, Clone)]
4pub enum LispError { 4pub enum LispError {
5 ParseError, 5 ParseError,
6 EvalError,
6} 7}