delay-frameclj

exit

no-loop

pop-style

push-style

redraw

start-loop

delay-frameclj

Arguments
[freeze-ms]
Docstring

Forces the program to stop running for a specified time. Delay times are specified in thousandths of a second, therefore the function call (delay 3000) will stop the program for three seconds. Because the screen is updated only at the end of draw, the program may appear to 'freeze', because the screen will not update when the delay-frame function is used. This function has no effect inside setup.

Works only inside sketch functions?
Yes
Original Processing method
delay()
Original p5js method
None.
Example
clojure specific
  • (q/background 127)
    (q/ellipse (* 5 (q/frame-count)) (* 5 (q/frame-count)) 50 50)
    ; delay frame for random duration between 0 and 2s
    (q/delay-frame (rand-int (* 500 (rand-int 4))))

exit

Arguments
[]
Docstring

Quits/stops/exits the program. Rather than terminating immediately, exit will cause the sketch to exit after draw has completed (or after setup completes if called during the setup method).

Works only inside sketch functions?
Yes
Original Processing method
exit()
Original p5js method
remove()
Example
(q/background 255)
(q/fill 0)
; exit sketch on 50th frame
(q/text (str "countdown " (- 50 (q/frame-count))) 20 20)
(when (= 50 (q/frame-count)) (q/exit))
try example

no-loop

Arguments
[]
Docstring

Stops Processing from continuously executing the code within draw. If start-loop is called, the code in draw will begin to run continuously again. If using no-loop in setup, it should be the last line inside the block.

When no-loop is used, it's not possible to manipulate or access the screen inside event handling functions such as mouse-pressed? or key-pressed?. Instead, use those functions to call redraw or loop which will run draw, which can update the screen properly. This means that when no-loop has been called, no drawing can happen, and functions like save-frame may not be used.

Note that if the sketch is resized, redraw will be called to update the sketch, even after no-loop has been specified. Otherwise, the sketch would enter an odd state until loop was called.

Works only inside sketch functions?
Yes
Original Processing method
noLoop()
Original p5js method
noLoop()
Example
(q/background 255)
(q/fill 0)
; pause sketch on every 10th frame
(when (zero? (rem (q/frame-count) 10))
  (q/no-loop)
  (q/text "paused, click to unpause" 10 20))
(q/text (str "(q/looping?) = " (q/looping?)) 10 40)
(q/text (str "frame: " (q/frame-count)) 10 60)
try example

pop-style

Arguments
[]
Docstring

Restores the prior settings on the 'style stack'. Used in conjunction with push-style. Together they allow you to change the style settings and later return to what you had. When a new style is started with push-style, it builds on the current style information. The push-style and pop-style functions can be nested to provide more control

Works only inside sketch functions?
Yes
Original Processing method
popStyle()
Original p5js method
pop()
Example
(q/background 255)
(q/fill 255 0 0)
(q/ellipse 125 125 100 100)
(q/push-style)
(q/fill 0 0 255)
(q/ellipse 250 250 100 100)
(q/pop-style)
(q/ellipse 375 375 100 100)
try example

push-style

Arguments
[]
Docstring

Saves the current style settings onto a 'style stack'. Use with pop-style which restores the prior settings. Note that these functions are always used together. They allow you to change the style settings and later return to what you had. When a new style is started with push-style, it builds on the current style information. The push-style and pop-style functions can be embedded to provide more control.

The style information controlled by the following functions are included in the style: fill, stroke, tint, stroke-weight, stroke-cap, stroke-join, image-mode, rect-mode, ellipse-mode, shape-mode, color-mode, text-align, text-font, text-mode, text-size, text-leading, emissive, specular, shininess, and ambient.

Works only inside sketch functions?
Yes
Original Processing method
pushStyle()
Original p5js method
push()
Example
(q/background 255)
(q/fill 255 0 0)
(q/ellipse 125 125 100 100)
(q/push-style)
(q/fill 0 0 255)
(q/ellipse 250 250 100 100)
(q/pop-style)
(q/ellipse 375 375 100 100)
try example

redraw

Arguments
[n]cljs[]
Docstring

Executes the code within the draw function one time (or n times in cljs). This function allows the program to update the display window only when necessary, for example when an event registered by mouse-pressed? or key-pressed? occurs.

In structuring a program, it only makes sense to call redraw within events such as mouse-pressed?. This is because redraw does not run draw immediately (it only sets a flag that indicates an update is needed).

Calling redraw within draw has no effect because draw is continuously called anyway.

Works only inside sketch functions?
Yes
Original Processing method
redraw()
Original p5js method
None.
Example
; 
; setup
; 
(q/no-loop)
; 
; draw
; 
(q/background 255)
(q/fill 0)
(q/text "click to move" 10 20)
(q/rect (* (q/frame-count) 10) (+ (* (q/frame-count) 10) 40) 50 50)
try example

start-loop

Arguments
[]
Docstring

Causes Processing to continuously execute the code within draw. If no-loop is called, the code in draw stops executing.

Works only inside sketch functions?
Yes
Original Processing method
loop()
Original p5js method
loop()
Example
(q/background 255)
(q/fill 0)
; pause sketch on every 10th frame
(when (zero? (rem (q/frame-count) 10))
  (q/no-loop)
  (q/text "paused, click to unpause" 10 20))
(q/text (str "(q/looping?) = " (q/looping?)) 10 40)
(q/text (str "frame: " (q/frame-count)) 10 60)
try example