aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/canvas-language.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/canvas-language.lisp')
-rw-r--r--src/canvas-language.lisp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/canvas-language.lisp b/src/canvas-language.lisp
index 8188e53..b90e22d 100644
--- a/src/canvas-language.lisp
+++ b/src/canvas-language.lisp
@@ -24,17 +24,18 @@
"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*))
- (*current-pen-color* ,(if color-supplied-p nil '*current-pen-color*))
- (*current-pen-width* ,(if width nil '*current-pen-width*)))
- ,(when position
- `(move-to ,@position))
- ,(when color-supplied-p
- `(canvas-pen-color ,color))
- ,(when width
- `(canvas-pen-width ,width))
- (with-current-pen
- ,@body)))
+ (with-gensyms (newpos)
+ `(let ((*current-pen-position* ,(if position nil '*current-pen-position*))
+ (*current-pen-color* ,(if color-supplied-p nil '*current-pen-color*))
+ (*current-pen-width* ,(if width nil '*current-pen-width*)))
+ ,(when position
+ `(let ((,newpos ,position)) (apply 'move-pen-to ,newpos)))
+ ,(when color-supplied-p
+ `(canvas-pen-color ,color))
+ ,(when width
+ `(canvas-pen-width ,width))
+ (with-current-pen
+ ,@body))))
(defmacro with-canvas (canvas &body body)
"Perform drawing commands in BODY using the value of CANVAS as the