// PROGRAMM START int level = 0; int[][] levelPixels; int imageWidth = 400; int currentPixelSize = 400; int pixelCount = 1; PImage orgImage; void setup() { size(imageWidth, imageWidth); background(255); levelPixels = new int[10][imageWidth*imageWidth]; orgImage = loadImage("Monroe.jpg"); draw(); } void draw() { if (pixelCount==1) { image(orgImage, 0, 0, 2, 2); color[] colors = new color[4]; color cp1 = get(0, 0); color cp2 = get(0, 1); color cp3 = get(1, 0); color cp4 = get(1, 1); float r = (red(cp1)+red(cp2)+red(cp3)+red(cp4))/4; float g = (green(cp1)+green(cp2)+green(cp3)+green(cp4))/4; float b = (blue(cp1)+blue(cp2)+blue(cp3)+blue(cp4))/4; background(r, g, b); } else { smooth(); image(orgImage, 0, 0, pixelCount, pixelCount); PImage cp = get(0,0,pixelCount,pixelCount); noSmooth(); image(cp, 0, 0, 400, 400); } } void mousePressed() { if (currentPixelSize==1) { return; } level++; currentPixelSize = (int)(Math.ceil(imageWidth * Math.pow(0.5, level))); pixelCount = imageWidth/currentPixelSize; println(currentPixelSize+" "+pixelCount); this.draw(); } // PROGRAMM ENDE