xxxxxxxxxx
35
let tvOn = true;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220, 220, 220);
noStroke(); // Remove outline for circles
if (tvOn) {
for (let i = 0; i < 5000; i++) {
let x = random(width);
let y = random(height);
fill(235, 154, 154);
circle(x, y, 4);
}
} else {
background(0); // Turn off the TV by setting the background to black
}
fill(170);
rect(0, 360, 400, 400);
fill(50);
circle(200, 380, 20);
}
function mousePressed() {
// Check if the mouse click is inside the button area
if (mouseX >= 190 && mouseX <= 210 && mouseY >= 360 && mouseY <= 390) {
tvOn = !tvOn; // Toggle the TV state (on/off)
}
}