One way to control when to run draw()
manually is to use noLoop()
and redraw()
:
function setup() {
createCanvas(400, 400);
background(220);
noLoop()
}
function draw() {
ellipse(random(width), random(height), 30, 30)
}
function mouseDragged() {
redraw()
}