JSUI graphics in ClojureScript.
example.cross: a pretty straight port of the one in the JSUI documentation
example.surface-work: work-in-progress from Darwin Grosse's November Patch-a-Day)
example.tickle: a more sophisticated annotation example for examining the objects in Max patchers
example.puffdrawDarwin's "Puffdraw" example
$ lein deps $ lein cljsbuild once dev (or) $ lein cljsbuild once prod
There are two build targets:
dev runs the Google Closure
compiler backend in minimal optimisation mode, whereas
prod turns on
further optimisation for "production" output. (This is what Google
Closure refers to as "simple" optimisation; the full-blown "advanced"
mode seems to be throwing up code generation errors in the ClojureScript
dev mode compiles faster, but
prod is fast enough to be usable
since we've taken out the "advanced" optimisation mode (which is slow).
The output of
dev, in this project, is
prod target writes
_main.js. Once one of these is built, you can
open any of the patchers in
jsui-cljs.maxproj in Max 6 to see the
result. (Any non-
msgraphics code would probably run in Max 5, but
you'd need to fix up the search path and load the patcher files
is determined by the JSUI argument. Look at
core to see the
selection on the ClojureScript side.
For general development, consider running
$ lein cljsbuild auto dev
prod) in the background: this automatically recompiles whenever any
(ClojureScript) sources are changed. If the source sets
1 (as in our examples), then changes to sources will automatically be
recompiled and reloaded into Max.
$ lein marg src-cljs/
"Advanced" optimisation in Google Closure merits some discussion. One of
the optimisations munges variable names, to make them shorter and more
efficient. We need to prevent munging of names we're using implicitly
from the Max world (
autowatch etc.), and also make sure
that we can plant names for JSUI to use which themselves won't get
munged. There's more detail here, but the upshot is that we need
to provide a mock externals file declaring stubs which shadow the things
src-cljs/externs.js, although it's currently far from
(For "simple" optimisation, there's no top-level variable renaming.)
Copyright © 2012 Nick Rothwell, email@example.com
Distributed under the Eclipse Public License, the same as Clojure.