set-state!

state

state-atom

set-state!

Arguments
[& state-vals]
Docstring
Set sketch-specific state. May only be called once (ideally in the
setup fn).  Subsequent calls have no effect.

Example:
(set-state! :foo 1 :bar (atom true) :baz (/ (width) 2))
Works only inside sketch functions?
Yes
Original Processing method
None. It is present only in Quil.
Example
; 
; setup
; 
(q/set-state! :text "I'm state!" :year (q/year))
; 
; draw
; 
(q/fill 0)
(q/text (q/state :text) 10 20)
(q/text (str "Full state: " (q/state)) 10 40)
try example

state

Arguments
[][key]
Docstring
Retrieve sketch-specific state by key. Must initially call
set-state! to store state. If no parameter passed whole
state map is returned.

(set-state! :foo 1)
(state :foo) ;=> 1
(state) ;=> {:foo 1}
Works only inside sketch functions?
Yes
Original Processing method
None. It is present only in Quil.
Example
; 
; setup
; 
(q/set-state! :text "I'm state!" :year (q/year))
; 
; draw
; 
(q/fill 0)
(q/text (q/state :text) 10 20)
(q/text (str "Full state: " (q/state)) 10 40)
try example

state-atom

Arguments
[]
Docstring
Retrieve sketch-specific state-atom. All changes to the
atom will be reflected in the state.

(set-state! :foo 1)
(state :foo) ;=> 1
(swap! (state-atom) update-in [:foo] inc)
(state :foo) ;=> 2
Works only inside sketch functions?
Yes
Original Processing method
None. It is present only in Quil.
Example

There are no examples for this function. You can request examples which will help us to prioritize this funciton.