aboutsummaryrefslogtreecommitdiff
path: root/src/lisp/prelude.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lisp/prelude.rs')
-rw-r--r--src/lisp/prelude.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/lisp/prelude.rs b/src/lisp/prelude.rs
index 6153e4f..d2a6ae6 100644
--- a/src/lisp/prelude.rs
+++ b/src/lisp/prelude.rs
@@ -1,7 +1,8 @@
1use crate::{ 1use crate::{
2 brush::Brush,
2 lisp::{ 3 lisp::{
3 error::{EvalError, LispError}, 4 error::{EvalError, LispError},
4 expr::{Arity, LispExpr}, 5 expr::{is_ident, Arity, LispExpr},
5 number::LispNumber, 6 number::LispNumber,
6 Environment, 7 Environment,
7 }, 8 },
@@ -193,5 +194,23 @@ pub fn new_env() -> Environment {
193 return Ok(LispExpr::Unit); 194 return Ok(LispExpr::Unit);
194 }); 195 });
195 196
197 primitive!(env, Arity::Atmost(1), "brush", |args, app| {
198 info!("brush {}", &args[0]);
199 if let [LispExpr::Quote(kind, _)] = args {
200 if is_ident(kind) {
201 match (&**kind).as_ref() {
202 "fill" => app.brush = Brush::Fill,
203 "circle" => app.brush = Brush::new(),
204 "line" => app.brush = Brush::line(0, false),
205 "line-extend" => app.brush = Brush::line(0, true),
206 _ => return Err(EvalError::CustomInternal("unknown brush type").into()),
207 }
208 }
209 } else {
210 return Err(EvalError::TypeMismatch.into());
211 }
212 return Ok(LispExpr::Unit);
213 });
214
196 env 215 env
197} 216}