Controllo del draw(): esempio
// height=100 lines=auto
let x;
function setup() {
createCanvas(670,100);
background( 220 );
x = 0;
frameRate(20);
}
function draw() {
x = x + 2;
let y = random( 46, 54 );
circle( x, y, 6 );
if (x > 300) {
noLoop();
}
}
frameRate(20);
Abbassa il numero di chiamate del draw() da 60 al secondo (default) a 20.
if (x > 300) {
noLoop();
}
Ferma le chiamate del draw() se il valore di x è superiore a 300.