int maxLength = 9999; int idCount = 0; SwirlParticle[] pt = new SwirlParticle[maxLength]; void setup() { size(400,400,P3D); frameRate(60); background(100); translate(width /2, 0, 0); } void draw() { background(100); if (mousePressed) { pt[idCount] = new SwirlParticle(idCount, mouseX, mouseY, 0); if (idCount < maxLength -1) { idCount ++; } } for (int i = 0; i < idCount; i ++) { pt[i].rotatePos(); if (i > 0) { stroke(map(pt[i].z,-width/2, width/2,100,255),100); line(pt[i-1].x + width/2, pt[i-1].y, pt[i-1].z,pt[i].x + width/2, pt[i].y, pt[i].z); } } } public class SwirlParticle { float x,y,z; float oridinalX; float angle; int col; SwirlParticle (int _id, float _x, float _y, float _z) { angle = 0; x = _x - width / 2; oridinalX = x; y = _y; z = _z; col = int(random(100)); } public void rotatePos() { angle += 1; z = sin(radians(angle)) * oridinalX; x = cos(radians(angle)) * oridinalX; } }