We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi!
I just want to use noLoop() in setup and therefore call only once the draw method but I want to update (to draw again) the sketch in some circumstances.
What's the best advice to achieve this?
I saw that in 'instance' mode it is needed a function f(sketch) that inside defines sketch.setup and sketch.draw and returns nothing.
I intend to define inside a function, let's say drawMethod and make the sketch.draw = drawMethod and finally return an object { draw: drawMethod } in order to expose the method to the outside world and be able to be called later.
I'm not sure if this is the recommended way or not.
Kind regards,
Radu Mirescu
Answers
@radumir -- re:
What circumstances? User input? A timed event?
If I'm understanding right you want to do something like this with
noLoop()
, an input event such askeyPressed()
, andredraw()
:...only using p5.js Instance mode. Is that right?
See this related discussion and reference:
...and more from the reference and examples:
https://forum.Processing.org/two/discussions/tagged?Tag=#instance+mode