int nowMx = 0; int nowMy = 0; int prevMx = 0; int prevMy = 0; void setup() { size(800, 600); smooth(); } void draw(){ int mx = nowMx - prevMx; int my = nowMy - prevMy; float d = sqrt(mx*mx + my*my); float r1 = random(d * -1, 0); float r2 = random(d * -2, d * 1); int n = floor(random(10,50)); drawStar(nowMx,nowMy,r1,r2,n); prevMx = nowMx; prevMy = nowMy; nowMx = mouseX; nowMy = mouseY; } void clear(){ stroke(200); fill(200); rect(0,0,width,height); } void drawStar(int x , int y , float r1,float r2 , int num){ stroke(0,0,0,100); float rad = TWO_PI / num; for ( int i=0; i< num; i++){ float p1x = r1 * cos(rad * i) +x; float p1y = r1 * sin(rad * i) +y; float p2x = r2 * cos(rad * (i + 0.5)) +x; float p2y = r2 * sin(rad * (i + 0.5)) +y; float p3x = r1 * cos(rad * (i+1)) +x; float p3y = r1 * sin(rad * (i+1)) +y; line(p1x,p1y,p2x,p2y); line(p2x,p2y,p3x,p3y); } }