xxxxxxxxxx
46
function setup() {
createCanvas(400, 400);
background(255);
textSize(12);
text('Light Value:', 15, 25);
fill(255, 0, 0);
rect(70, 5, 45, 35, 5, 5, 5, 5);
let button = createButton("Generate Value for Light");
button.mousePressed(randomValue);
let button2 = createButton("Restart");
button2.mousePressed(clearEverything);
}
function draw() {
}
function randomValue() {
let lightnum = int(random(0,50));
textSize(32);
//fill(10);
stroke(0);
fill(10);
//background(30, 180, 200);
//strokeWeight(1);
text(lightnum, 75, 8, 50, 80);
fill(255, 0, 0);
rect(70, 5, 45, 35, 5, 5, 5, 5);
}
function clearEverything() {
background(255);
}
function keyPressed(){
if(keyCode === LEFT_ARROW){
background(100, 50, 60);
}
}