/** * After dark. Eine Hommage an den lagendŠren Screensaver. * * (c) Team Plan B, 02. April 2008 * * Basiert auf folgenden processing Demo-Programmen: * brightness, displaying, handles, letters */ PImage img; int skyB, skyH, lampB, lampH; void setup() { // Bild laden und User Interface zeichnen size(740,480); img = loadImage("manhattan.jpg"); image(img, 0, 0); PFont fontA = loadFont("TheSans-Plain-12.vlw"); textFont(fontA, 12); textAlign(CENTER); fill(32); text("SKY", 690, 30); text("LIGHT", 690, 280); text("+",670,50); text("+",710,50); text("-",670,200); text("-",710,200); text("B",670,215); text("H",710,215); text("+",670,300); text("+",710,300); text("-",670,450); text("-",710,450); text("B",670,465); text("H",710,465); lampB=180; skyB=180; drawrect(); } void draw() { loadPixels(); colorMode(HSB, 255); for (int x = 0; x < 640; x++) { for (int y = 0; y < 480; y++ ) { int loc = x + y*640; // Position im Foto int loc2 = x + y*740; // Position am Schirm float h,b,s; h = hue (img.pixels[loc]); b = brightness (img.pixels[loc]); s = saturation (img.pixels[loc]); float d = dist(x,y,mouseX,mouseY); // Abstand vom Mauszeiger berechnen boolean mausbereich=true; if (mouseX<640 && mouseX>5 && mouseY>5 && mouseY<475 && d<50) {mausbereich = false;} if (h>150 && h<170 && b>128 && mausbereich) // Bereich "Himmel" = blau und hell { h += skyH; h = h%255; b += (skyB-180); } else { if ( h>0 && h<70 && mausbereich ) // Bereich "Licht" = gelb { h += lampH; h = h%255; b += (lampB-180); } } h = constrain(h,0,255); b = constrain(b,0,255); color c = color(h,s,b); pixels[loc2] = c; } } updatePixels(); } void mouseReleased() // Inspiriert von "handles" { int step=10; if (overRect(660,40,20,20)) { skyB+= step; } if (overRect(700,40,20,20)) { skyH+= step; } if (overRect(660,190,20,20)) { skyB-= step; } if (overRect(700,190,20,20)) { skyH-= 20; } skyH = (250+skyH) % 250; skyH=constrain(skyH,0,250); skyB=constrain(skyB,0,360); if (overRect(660,290,20,20)) { lampB+= step; } if (overRect(700,290,20,20)) { lampH+= step; } if (overRect(660,440,20,20)) { lampB-= step; } if (overRect(700,440,20,20)) { lampH-= step; } lampH = (250+lampH) % 250; lampH=constrain(lampH,0,250); lampB=constrain(lampB,0,360); drawrect(); } void drawrect() { fill(192); rect(660,60,20,120); //rect(700,60,20,120); rect(660,310,20,120); // rect(700,310,20,120); ellipse(710,120,40,40); ellipse(710,370,40,40); fill(128); rect(660,60,20,skyB/3); //rect(700,60,20,skyH/2); rect(660,310,20,lampB/3); // rect(700,310,20,lampH/2); arc(710, 120,40, 40, 0, float(skyH)/240*TWO_PI); arc(710, 370,40, 40, 0, float(lampH)/240*TWO_PI); } boolean overRect(int x, int y, int width, int height) // Entnommen von "handles" { if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) { return true; } else { return false; } }