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/prelude.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/lisp/prelude.rs') 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