Closed Kevinpgalligan closed 7 months ago
As a workaround right now you can do that with kit.sdl2
:
;;; test should name a sketch
* (make-instance 'test)
; => #<TEST {1006764313}>
* (setf (kit.sdl2:idle-render *) nil) ; stops redrawing the sketch automatically
; => T
* (kit.sdl2:render (kit.sdl2:last-window)) ; redraws the last window
; => NIL
* (defmethod kit.sdl2:mousebutton-event ((window test) st ts but x y)
;; redraw the window on each mouse button click
(when (eq st :mousebuttondown)
(kit.sdl2:render window)))
; => #<STANDARD-METHOD KIT.SDL2:MOUSEBUTTON-EVENT (TEST T T T T T) {1005E3AF33}>
Done! We could consider adding the function to trigger redraws, but I can't think of any application that can't be achieved with start & stop functions.
If drawing a static sketch (i.e. with no moving parts), then it seems wasteful to repeatedly call the
(draw)
function. Personally, I find it annoying when my laptop fan continues going crazy even after all the drawing has supposedly been completed.p5js provides
loop()
,noLoop()
andredraw()
functions to alter the control flow. After drawing a static picture, for example,noLoop()
can be called and no unnecessary CPU churn will take place afterwards. Another example: the user could click their mouse to start and stop a drawing loop.So, my suggestion is to add the equivalent of these functions to sketch. I'm not sure how they would interact with redefinitions - I suppose that the loop would be started again once the sketch is redefined?
References: