Hi, I have a question about quil library. How to I call individual functions in the REPL, e.g. quil.core/random? Most quil function can only be run inside sketch functions (I think because of state handling). Is the any way to grab the current state in the repl and execute code?
processing functions are defined in applet class, so every wrapper needs this context.
some of the functions are static (like map) but some of them are not (like random)
current context (applet) can be access via quil.applet/current-applet
or quil.applet/*applet*
dynamic var
thanks. I'll try this
Actually my question is part of a bigger thing I'm struggling with. I'm quite new to clojure, quil and all the tooling around. Currently I follow the workflow as described here (with fun-mode)
https://github.com/quil/quil/wiki/Dynamic-Workflow-(for-REPL)
That means: open a repl, load the main file (where the defsketch
macro is) and then actual implementation (called dynamic.clj
in the tutorial), i.e. the setup
, draw
and update
functions. Now I start coding by e.g. altering (defn update-state)
followed by either reevaluation of that function or reloading that the whole file (i.e. (use :reload 'sketch.dynamic)
.
However, actually I would like to pause the sket (i.e. the draw loop), play along with functions (figure out what they do and how they work), e.g. quil.core/random and continue the draw loop. But I don't known how to accomplish this.
In my current approach the code must be perfect otherwise I get constantly errors, because of the repeated update/draw calls.
quil directly follows processing concept which can be somehow limiting
if you do not aim for web you can try some alternative like my clojure2d/fastmath
where I removed this constrains and decoupled canvas/window/sketch
Does quil support my intended workflow, i.e. starting stopping the draw loop or did I miss something (do something wrong)?
there is an option to stop and run loop via no-loop
and loop
ok. but they need the context as well (like you posted above with current-applet
)
right...
you can always define an atom and check the atom inside draw
that sounds interesting. But like I said, I'm new to clojure. Could you provide an example or a link for further documentation?
for using atoms?
yes. I don't understand what you mean with "always define an atom and check the atom inside"
just define an atom somewhere in the script (def running? (atom true))
and access it from draw
or outside draw