From e18777e32448f465748535690666055c179d5d5f Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 28 Mar 2021 12:58:58 +0530 Subject: add better brush drawing feedback --- src/lisp/eval.rs | 2 +- src/lisp/expr.rs | 2 +- src/lisp/prelude.rs | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/lisp') diff --git a/src/lisp/eval.rs b/src/lisp/eval.rs index 6ffff23..f7f918a 100644 --- a/src/lisp/eval.rs +++ b/src/lisp/eval.rs @@ -4,7 +4,7 @@ use crate::{ error::{EvalError, LispError}, expr::{Arity, Ident, LispExpr, LispFunction}, number::LispNumber, - EnvList, Environment, + Environment, }, }; diff --git a/src/lisp/expr.rs b/src/lisp/expr.rs index 9ef9f65..8fd794e 100644 --- a/src/lisp/expr.rs +++ b/src/lisp/expr.rs @@ -5,7 +5,7 @@ use crate::lisp::{ error::{EvalError, LispError}, eval::lookup_extended, number::LispNumber, - EnvList, Environment, + EnvList, }; #[derive(Debug, Copy, PartialEq, Clone)] diff --git a/src/lisp/prelude.rs b/src/lisp/prelude.rs index d2a6ae6..bdaf639 100644 --- a/src/lisp/prelude.rs +++ b/src/lisp/prelude.rs @@ -9,7 +9,7 @@ use crate::{ primitive, }; -use std::{convert::TryInto, fs::File, io::Write, path::PathBuf}; +use std::{convert::TryInto, fs::File, io::Write}; use log::info; @@ -196,13 +196,18 @@ pub fn new_env() -> Environment { primitive!(env, Arity::Atmost(1), "brush", |args, app| { info!("brush {}", &args[0]); + let old_size = if matches!(app.brush, Brush::Line { .. } | Brush::Circle { .. }) { + app.brush.size().unwrap() + } else { + 0 + }; if let [LispExpr::Quote(kind, _)] = args { if is_ident(kind) { match (&**kind).as_ref() { "fill" => app.brush = Brush::Fill, - "circle" => app.brush = Brush::new(), - "line" => app.brush = Brush::line(0, false), - "line-extend" => app.brush = Brush::line(0, true), + "circle" => app.brush = Brush::new(old_size), + "line" => app.brush = Brush::line(old_size, false), + "line-extend" => app.brush = Brush::line(old_size, true), _ => return Err(EvalError::CustomInternal("unknown brush type").into()), } } -- cgit v1.2.3