static int circleSize = 30; static int screenSize = 500; static int maxFades = 20; int[] miceX = new int[maxFades]; int[] miceY = new int[maxFades]; int intensity = 0; void setup () { size(screenSize, screenSize); noStroke(); smooth(); fill(255); } void draw() { background (10); /*This code grabs the new mouse position, and bumps the array of old mouse positions "forward", starting from the back and pushing each value up one place in line.*/ miceX[0] = mouseX; miceY[0] = mouseY; for (int i = maxFades-1; i>=1; i--) { //print(miceX[i]+"."); miceX[i] = miceX[i-1]; //print(miceY[i]+","); miceY[i] = miceY[i-1]; } println(); //This sets the number of circles drawn based on the y position. intensity = (miceY[0] / (screenSize/(maxFades-1))); //This is the brightness in each drawn circle, set by default to "full". int circleAlpha = 255; //This loop draws the circles, as many as are needed. */ for (int i=intensity; i>=0; i--) { //The greyscale will be exponentially darker in later circles. //It looks better that way. circleAlpha = 255/(i+1); // println(circleAlpha); fill(circleAlpha); ellipse (miceX[i],miceY[i],circleSize,circleSize); } }