> show canvas only <


/* built with Studio Sketchpad: 
 *   http://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   http://studio.sketchpad.cc/sp/pad/view/ro.NWkrNwTKFMc/rev.6
 * 
 * authors: 
 *   GoToLoop

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   http://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



/**
 * Mouse Trace Array (v1.0)
 * by GoToLoop (2014/Mar)
 *
 * forum.processing.org/two/discussion/3437/how-to-create-a-mouse-trace
 *
 * studio.processingtogether.com/sp/pad/export/ro.9ldYvJUyiXGzi/latest
 */

static final int NUM = 0300, NEWEST = NUM - 1;
final int[] x = new int[NUM], y = new int[NUM];

void setup() {
  size(800, 600, JAVA2D);
  
  colorMode(RGB, NEWEST);
  frameRate(60);
  smooth(4);
  strokeWeight(1);

  mouseX = width>>1;
  mouseY = height>>1;

  for (int i = NUM; i-- != 0; x[i] = mouseX, y[i] = mouseY);
}

void draw() {
  background(0);

  for (int i = 0; i != NEWEST;) {
    stroke(0, i, 0);
    line(x[i], y[i], x[i] = x[i + 1], y[i] = y[++i]);
  }

  x[NEWEST] = mouseX;
  y[NEWEST] = mouseY;
}