xxxxxxxxxx
// User settings
var trailLength = 200;
var segmentSize = 20;
var colorSpeed = 1;
var innerColorSpeed = 5;
// Global variables
var trail = [];
var h = 0;
function setup() {
createCanvas(500, 500);
colorMode(HSB);
noStroke();
}
function draw() {
background(255);
trail.push({
'x': mouseX,
'y': mouseY
});
var thisColor = h;
for (var i = 0; i < trail.length; i++) {
fill(thisColor, 100, 100);
var seg = trail[i];
ellipse(seg.x, seg.y, segmentSize, segmentSize);
thisColor = (thisColor + innerColorSpeed) % 360;
}
if (trail.length > trailLength) {
trail.splice(0, max(trail.length - trailLength, 0));
}
h = (h + colorSpeed) % 360;
}