xxxxxxxxxx
31
let nameInput;
let colors = [];
function setup() {
createCanvas(400, 400);
background(220);
colorMode(HSB);
nameInput = select('.color');
nameInput.changed(getName);
frameRate(10);
textSize(32);
}
function draw() {
for(let i = 0; i < colors.length; i = i + 1) {
background(colors[i],colors[i],colors[i]);
}
}
function getName() {
colors.push(nameInput.value());
if(nameInput.value() == "360") {
text("red",random(width),random(height));
} else if (nameInput.value() == "200") {
text("blue",random(width),random(height));
} else if (nameInput.value() == "100") {
text("green",random(width),random(height));
}
nameInput.value("");
}