Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inspect state in fun-mode in Quil using the REPL?

Tags:

clojure

quil

I'm writing a sketch in Clojure/Quil in fun(ctional)-mode.

Sometimes, I want to be able to inspect what the current state holds.

However, when I try to call Quil's state from the REPL I get the following:

(q/state) ==>
NullPointerException   clojure.core/deref-future (core.clj:2208)

Not sure if this is relevant, but the same happens with drawing functions from the REPL:

(q/rect 0 0 10 10)

How can I get the current state to inspect it in the REPL?

like image 434
cwj Avatar asked May 29 '26 04:05

cwj


1 Answers

Not sure which function exactly you are talking about since you do not post code so this is a bit of a blind shot.

You could try to see the state-atom:

(require '[quil.core :as q])

;; both should do the same

@(q/state-atom)
(q/state) ;; is that what you were doing ?

The state function you seem to refer to optionally takes a parameter, for instance, and returns the state-atom when no parameter is passed:

(q/state :image)

In any case, it is generally a good idea to look at the tests of a Clojure library, and the code in this case seems very well documented.

like image 190
nha Avatar answered Jun 01 '26 03:06

nha