Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (28 sloc) 868 Bytes
(ns moarquil.util
Utilities namespace.
(:require [quil.core :refer :all]))
(defmacro defcontext
Create a contextual macro[1] with setup and teardown. The teardown
executes even if the body raises an exception.
[1] Macro-writing-macros hurt my brain. This helps:
See also:
[nom setup teardown]
`(defmacro ~(symbol (str "with-" nom))
[~'& body#]
;; The actual context macros, with specified setup and teardown steps.
;; Example usage: `(with-style ...body... )`.
(defcontext style (push-style) (pop-style))
(defcontext shape (begin-shape) (end-shape))
(defcontext matrix (push-matrix) (pop-matrix))