Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;The following macro doesn't expand properly?:
- (defmacro make-path [[x y]]
- `(path [] (move-to ~x ~y))
- )
- ;note the nil path2206. Ideally that'd expand to (.moveTo path2206 10 10):
- (macroexpand
- '(make-path [10 10]))
- (let* [path2206 (java.awt.geom.Path2D$Double.)] (.moveTo path2206 0 0) (nil path2206 10 10) path2206)
- ;Here's how the seesaw macro looks like:
- ;(def ^{:private true} path-ops {
- ; 'line-to '.lineTo
- ; 'move-to '.moveTo
- ; 'curve-to '.curveTo
- ; 'quad-to 'quad-to
- ;})
- ;
- ;(defmacro path [opts & forms]
- ; (when (not (vector? opts)) (illegal-argument "path must start with vector of (possibly ;empty) options"))
- ; (let [p (gensym "path")]
- ; `(let [~p (java.awt.geom.Path2D$Double.)]
- ; ; Insert an initial moveTo to avoid needless exceptions
- ; (.moveTo ~p 0 0)
- ; ~@(for [f forms]
- ; (cons (get path-ops (first f)) (cons p (rest f))))
- ; ~p)))
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement