Fork me on GitHub
#quil
<
2019-01-12
>
jradek13:01:18

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?

genmeblog15:01:02

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

genmeblog15:01:02

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

genmeblog15:01:27

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

genmeblog15:01:57

or quil.applet/*applet* dynamic var

jradek15:01:08

thanks. I'll try this

jradek15:01:47

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.

genmeblog15:01:18

quil directly follows processing concept which can be somehow limiting

genmeblog15:01:47

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

genmeblog15:01:16

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

jradek16:01:54

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

genmeblog16:01:35

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

jradek16:01:45

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

genmeblog18:01:07

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

jradek18:01:02

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

genmeblog19:01:22

for using atoms?

jradek20:01:07

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

genmeblog20:01:31

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

genmeblog20:01:19

and access it from draw or outside draw