Press any key for a purple circle, yellow background. Click for a yellow circle, purple background. Press Z to stop (white square, black background)
xxxxxxxxxx
function setup() {
createCanvas(400, 400);
rectMode(CENTER);
}
function draw() {
background(0);
frameRate(3);
fill(random(0, 255), random(0, 255), random(0, 255));
rect(200, 200, frameCount);//frameCount increases the count per frame
if(mouseIsPressed){
background(136, 72, 171);
fill(255, 250, 99);
circle(200, 200, 200);
}
if(keyIsPressed){
background(255, 250, 99);
fill(136, 72, 171);
circle(200, 200, 200);
}
}
function keyPressed(){
if(key === 'z'){
background(0);
fill(255);
rect(200, 200, 200);
frameRate(0);
}
}