/** Lensflare by guru */ PImage l; void setup() { size(300,300); smooth(); PGraphics tmp = createGraphics( 100,100,P2D); tmp.beginDraw(); tmp.background(0); tmp.fill(255); tmp.ellipse( 50,50,40,40); tmp.filter( BLUR, 4); tmp.ellipse( 50,50,40,40); tmp.filter( BLUR, 4); tmp.endDraw(); l = tmp; } void draw() { float dx = 150 - mouseX; float dy = 150 - mouseY; background(64 - 64 * sqrt(sqrt( sq( dx/150 ) + sq(dy/150)))); stroke( 0, 0, 230, 150); fill( 0,0, 230, 80); filter(BLUR,2); shape( 150 - dx/2, 150 - dy/2, 5, 30); stroke( 0, 230, 0, 150); fill( 0,230, 0, 80); filter(BLUR,2); stroke( 130, 0, 0, 150); fill( 130,0, 0, 80); shape( 150 - dx/5, 150 - dy/5, 6, 7); stroke( 230, 0, 230, 150); fill( 230,0, 230, 40); shape( 150 + dx/2, 150 + dy/2, 6, 30); stroke( 230, 230, 130, 150); fill( 230,230, 130, 80); shape( 150 + dx/8, 150 + dy/8, 6, 10); stroke( 0, 0, 130, 250); fill( 0,0, 130, 80); shape( 150 + dx/5, 150 + dy/5, 5, 10); filter( BLUR,2); filter(BLUR,2); blend( l, 0,0,l.width,l.height,mouseX - l.width/2, mouseY -l.height/2, l.width, l.height,ADD ); } void shape( float x, float y, int n, float r ) { pushMatrix(); translate( x, y); float a = TWO_PI/float(n); beginShape(); for( int i =0; i < n; i++) { vertex( r * cos( a * i ), r * sin( a * i)); } endShape(CLOSE); popMatrix(); }