Februar 23, 2012
PImage img; boolean showPic = true; int[] r, g, b; int maxColor; void setup() { img = loadImage("hunde.jpg"); size(img.width, img.height); r = new int[256]; g = new int[256]; b = new int[256]; loadPicture(); noStroke(); smooth(); } void loadPicture() { // new pixels img.loadPixels(); // get pixels for (int x = 0; x < img.width; x++ ) { for (int y = 0; y</pre> <img alt="" /> <pre> maxColor) { maxColor = g[i]; } if(b[i] > maxColor) { maxColor = b[i]; } } } void draw() { background(0); image(img, 0, 0); if (!showPic) { fill(0,200); rect(0,0,width,height); for (int i = 0;i<r.length;i++) { stroke(255, 0, 0,200); line(i*2, height, i*2, height-r[i]*height/maxColor); stroke(0, 255, 0,200); line(i*2, height, i*2, height-g[i]*height/maxColor); stroke(0, 0, 255,200); line(i*2, height, i*2, height-b[i]*height/maxColor); } } } void keyPressed() { if (key == ' ') { showPic = !showPic; } }