color daColor; PImage daPic; int dotSpacing, maxDotSize; float brightestPixel, dotSize; void setup() { maxDotSize = 20; dotSpacing = 7; //dotSize = 7; daPic = loadImage("pretty.jpg"); background(255); size(500,333); noStroke(); smooth(); //noLoop(); } void draw() { brightnessCheck(); int counter = 0; //dotSpacing = (int)map(mouseY, 0, height, 0, 20); for(int b = dotSpacing/2; b < height; b = b + dotSpacing){ for(int a = dotSpacing/2; a < width; a = a + dotSpacing){ //daColor = daPic.get(a, b); daColor = pixels[counter]; int pixelValue = pixels[counter]; float pixelBrightness = brightness(pixelValue); fill(daColor); dotSize = map(pixelBrightness, brightestPixel, 0, 0, maxDotSize); ellipse(a,b,dotSize,dotSize); counter = counter + dotSpacing; } counter = counter + ((width-(width/(dotSpacing)))*dotSpacing); //println(counter); } } void brightnessCheck(){ image(daPic,0,0); loadPixels(); background(255); for(int h = 0; h < pixels.length; h++){ int pixelValue = pixels[h]; // Determine the brightness of the pixel float pixelBrightness = brightness(pixelValue); // If that value is brighter than any previous, then store the // brightness of that pixel, as well as its (x,y) location if (pixelBrightness > brightestPixel) { brightestPixel = pixelBrightness; } } } void keyPressed(){ if(key == '=' || key == '+'){ dotSpacing = dotSpacing + 1; } if(key == '-' || key == '_'){ dotSpacing = dotSpacing - 1; } }