//BrushStrokes - Visuals-only applet version of the BrushStrokes // VST plugin. PImage mousePoint; int xPos; int yPos; int[] xPrev; int[] yPrev; void setup() { int x, y; int tempint; float tempf; xPos = 0; yPos = 0; xPrev = new int[64]; yPrev = new int[64]; //Setup mousePoint image. mousePoint = new PImage(16, 16); for(y=0;y<16;++y) { for(x=0;x<16;++x) { tempf = sin(((float)x/16.0)*PI); tempf *= sin(((float)y/16.0)*PI); tempf = (exp(tempf)-1.0)/(exp(1.0)-1.0) * 1.5 - 0.1; if(tempf < 0.0) tempf = 0.0; else if(tempf > 1.0) tempf = 1.0; tempint = (int)(tempf * 255.0); mousePoint.pixels[(y*16)+x] = color(255, 0, 0, tempint); } } size(320, 240); frameRate(30); smooth(); } void draw() { int i; float tempf; noStroke(); //Update trail stuff. for(i=63;i>0;--i) { xPrev[i] = xPrev[i-1]; yPrev[i] = yPrev[i-1]; } xPrev[0] = xPos; yPrev[0] = yPos; background(255); //Draw trail. for(i=1;i<64;++i) { tempf = (1.0-((float)i/64.0)) * 5.0; fill(255, 0, 0, (255-(int)(255.0*((float)i/64.0)))); quad(xPrev[i-1], (yPrev[i-1]+tempf), xPrev[i], (yPrev[i]+tempf), xPrev[i], (yPrev[i]-tempf), xPrev[i-1], (yPrev[i-1]-tempf)); } //Draw mouse pointer. image(mousePoint, xPos-8, yPos-8); //Draw dotted outline. /*stroke(127); for(i=0;i<320;i+=2) { point(i, 0); point(i, 239); } for(i=0;i<240;i+=2) { point(0, i); point(319, i); }*/ } void mouseMoved() { xPos = mouseX; yPos = mouseY; }