xxxxxxxxxx
39
let currentState = 0;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
if(currentState == 1) {
rect(100,100,200,100);
} else if(currentState == 2) {
ellipse(100,100,20);
}
}
function randomShapes() {
textSize(100);
push();
translate(random(width), random(height));
if(key == '1') {
text(key, 0,0);
} else if(key == '2') {
rect(0,0,100,100);
}
else if(key == '3') {
ellipse(0,0,100,100);
}
pop();
}
function keyPressed() {
currentState = 1;
}
function keyReleased() {
currentState = 2;
}