quil

jradek 2019-01-12T13:26:18.005600Z

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?

genmeblog 2019-01-12T15:08:02.007Z

processing functions are defined in applet class, so every wrapper needs this context.

genmeblog 2019-01-12T15:09:02.007500Z

some of the functions are static (like map) but some of them are not (like random)

genmeblog 2019-01-12T15:10:27.008500Z

current context (applet) can be access via quil.applet/current-applet

genmeblog 2019-01-12T15:10:57.008900Z

or quil.applet/*applet* dynamic var

jradek 2019-01-12T15:24:08.010Z

thanks. I'll try this

jradek 2019-01-12T15:25:47.012Z

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.

genmeblog 2019-01-12T15:32:18.012600Z

quil directly follows processing concept which can be somehow limiting

genmeblog 2019-01-12T15:32:47.013300Z

if you do not aim for web you can try some alternative like my clojure2d/fastmath

genmeblog 2019-01-12T15:33:16.014Z

where I removed this constrains and decoupled canvas/window/sketch

jradek 2019-01-12T16:00:54.016500Z

Does quil support my intended workflow, i.e. starting stopping the draw loop or did I miss something (do something wrong)?

genmeblog 2019-01-12T16:11:35.017600Z

there is an option to stop and run loop via no-loop and loop

jradek 2019-01-12T16:13:45.018600Z

ok. but they need the context as well (like you posted above with current-applet)

genmeblog 2019-01-12T16:21:41.019Z

right...

genmeblog 2019-01-12T18:29:07.019800Z

you can always define an atom and check the atom inside draw

jradek 2019-01-12T18:56:02.020900Z

that sounds interesting. But like I said, I'm new to clojure. Could you provide an example or a link for further documentation?

genmeblog 2019-01-12T19:05:22.021100Z

for using atoms?

jradek 2019-01-12T20:09:07.021800Z

yes. I don't understand what you mean with "always define an atom and check the atom inside"

genmeblog 2019-01-12T20:56:31.022900Z

just define an atom somewhere in the script (def running? (atom true))

genmeblog 2019-01-12T20:58:19.024800Z

and access it from draw or outside draw