//created by luis gil //www.legil.org int numSpots = 1131; Light[] spots = new Light[numSpots]; color nextColor = color(255, 0, 0); void setup() { size(484, 380); randomSeed(0); int x = 16; int y = 12; for ( int i = 0; i < numSpots; i++) { spots[i] = new Light(x, y, 8, nextColor); x += 12; if ((x > (width-7)) && (y%12 == 0 ) && (y%24 == 0)) { x = 16; y += 12; } else if (x > (width-7) && y%12 == 0) { x = 10; y += 12; } //else if (x > width-7 } noStroke(); fill(255, 0, 0); rect(6, 360, 60, 12); } void draw() { background(0); noStroke(); fill(255, 0, 0); rect(2, 360, 80, 12); fill(0, 255, 0); rect(82, 360, 80, 12); fill(0, 0, 255); rect(162, 360, 80, 12); fill(255, 255, 0); rect(242, 360, 80, 12); fill(0, 255, 255); rect(322, 360, 80, 12); fill(255, 255, 255); rect(402, 360, 80, 12); for (int i = 0; i < numSpots; i++) { spots[i].display(); } } void mousePressed() { float mx = mouseX; float my = mouseY; if (mx < 82 && mx > 2 && my > 360 && my < 372) { nextColor = color(255, 0, 0); } else if(mx < 162 && mx > 82 && my > 360 && my < 372) { nextColor = color(0, 255, 0); } else if (mx < 242 && mx > 162 && my > 360 && my < 372) { nextColor = color(0, 0, 255); } else if (mx < 322 && mx > 242 && my > 360 && my < 372) { nextColor = color(255, 255, 0); } else if (mx < 402 && mx > 322 && my > 360 && my < 372) { nextColor = color(0, 255, 255); } else if (mx < 482 && mx > 402 && my > 360 && my < 372) { nextColor = color(255, 255, 255); } else { for (int i = 0; i < numSpots; i++) { if (dist(spots[i].x, spots[i].y, mouseX, mouseY) < spots[i].sizeOf/2) { spots[i].press(mx, my); println("mp\n"); } } } } void keyPressed() { for (int i = 0; i < numSpots; i++) { if (key == 'x' || key == 'X') { spots[i].clicked = false; } } if (key == 's' || key == 'S') { save("lightBright.png"); } }