// image patterns based on "pattern" example by REAS // showcases some of the new imaging functions and blend modes int t0; int delayT; BImage brush,colFade,bgFade; void setup() { size(500, 250); background(0); // create image to tint pixel buffer colFade=new BImage(1,1); colFade.set(0,0,0x01ff0000); // set pixel to red with minimal alpha (01) // create image to fade out to black, alpha again very low // use very low alpha value // the alpha value is stored in the highest byte (bits 24-31) of // a packed colour integer bgFade=new BImage(1,1); bgFade.set(0,0,0x02000000); brush=loadImage("brush.jpg"); // fade out delay time 100ms delayT=100; t0=millis(); } void loop() { if (millis()-t0>delayT) { // blend in black image every 1/10secs blend(bgFade,0,0,1,1,0,0,width,height,BLEND); t0=millis(); } // tint image every frame blend(colFade,0,0,1,1,0,0,width,height,BLEND); // apply brush variableBrush(mouseX, mouseY, pmouseX, pmouseY); } // resize brush to current mouse speed void variableBrush(int x, int y, int px, int py) { int speed = (abs(x-px) + abs(y-py))/2; blend(brush,0,0,brush.width,brush.height,x-speed,y-speed,x+speed,y+speed,ADD); }