PImage img; void setup() { size(500, 500); img = createImage(500, 500, RGB); for (int i = 0; i < img.pixels.length; i++) { img.pixels[i] = color(255,255,255); } } void draw(){ updateGraphics(); madoake(); } void updateGraphics(){ // if (frameCount % 5 != 0) return; int x_p = int(random(480)); int y_p = int(random(490)); for (int x = x_p; x < x_p+20; x++) { for (int y = y_p; y < y_p+10; y++ ) { int loc = x + y*img.width; color c = color(frameCount * 20 % 255,random(100),100); img.pixels[loc] = c; } } } void madoake(){ loadPixels(); for (int x = 0; x < img.width; x++) { for (int y = 0; y < img.height; y++ ) { int loc = x + y*img.width; float r = red (img.pixels[loc]); float g = green (img.pixels[loc]); float b = blue (img.pixels[loc]); float distance = dist(x,y,mouseX,mouseY); float adjustBrightness = (100-distance)/100; r *= adjustBrightness; g *= adjustBrightness; b *= adjustBrightness; r = constrain(r,0,255); g = constrain(g,0,255); b = constrain(b,0,255); color c = color(r,g,b); pixels[loc] = c; } } updatePixels(); }