aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/canvas-language.lisp21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/canvas-language.lisp b/src/canvas-language.lisp
index fb3b679..8188e53 100644
--- a/src/canvas-language.lisp
+++ b/src/canvas-language.lisp
@@ -8,11 +8,11 @@
(defvar *current-pen-position* '(0 0))
(defvar *saved-state* nil)
-(defmacro with-current-pen-state ( &body body)
+(defmacro with-current-pen ( &body body)
"Saves the current pen state (color width position) so that it can
be restored from using (restore-pen-state) from within the BODY.
After BODY executes the state is restored to whatever it was
- before WITH-CURRENT-PEN-STATE was evaluated."
+ before WITH-CURRENT-PEN was evaluated."
`(let
((*saved-state*
(list *current-pen-width*
@@ -21,7 +21,7 @@
,@body))
(defmacro with-pen ((&key position (color nil color-supplied-p) width) &body body)
- "Like WITH-CURRENT-PEN-STATE, but lets you set the state of the pen
+ "Like WITH-CURRENT-PEN, but lets you set the state of the pen
EXECUTION BODY. After BODY executes, the state is restored to
whatever it was before WITH-PEN-STATE was evaluated."
`(let ((*current-pen-position* ,(if position nil '*current-pen-position*))
@@ -33,16 +33,9 @@
`(canvas-pen-color ,color))
,(when width
`(canvas-pen-width ,width))
- (with-current-pen-state
+ (with-current-pen
,@body)))
-(defmacro with-pen-color (list-or-fn &body body)
- "Temporarily bind pen color to the value of LIST-OR-FN and execute BODY."
- `(let ((*current-pen-color* nil))
- (canvas-pen-color ,list-or-fn)
- ,@body))
-
-
(defmacro with-canvas (canvas &body body)
"Perform drawing commands in BODY using the value of CANVAS as the
target of any drawing operations."
@@ -50,7 +43,7 @@
(*current-pen-width* 1)
(*current-pen-position* (list 0 0))
(*current-pen-color* (list 0 0 0 255)))
- (with-current-pen-state
+ (with-current-pen
,@body)))
(defun restore-pen ()
@@ -103,11 +96,11 @@ integer."
(destructuring-bind (cx cy) *current-pen-position*
(loop for (x y) in path collect (list (+ cx x) (+ cy y)))))
-(defun move-to (x y)
+(defun move-pen-to (x y)
"Sets the pen's position without drawing. "
(setf *current-pen-position* (list x y)))
-(defun move-rel (dx dy)
+(defun move-pen-rel (dx dy)
"Moves the current pen by dx dy."
(setf *current-pen-position*
(mapcar #'+ *current-pen-position* (list dx dy))))