voidoneStep() { background(51); println("frameCount: "+frameCount); //Shift all elements 1 place to the left for(inti=1; i < num; i++) { ax[i-1] = ax[i]; ay[i-1] = ay[i]; }
// Put a new value at the end of the array ax[num-1] += random(-range, range); ay[num-1] += random(-range, range);
// Constrain all points to the screen ax[num-1] = constrain(ax[num-1], 0, width); ay[num-1] = constrain(ay[num-1], 0, height); // Draw a line connecting the points for(int i=1; i<num; i++) { floatval=float(i)/num * 204.0 + 51; stroke(val); line(ax[i-1], ay[i-1], ax[i], ay[i]); } }
Reprint policy:
All articles in this blog are used except for special statements
CC BY 4.0
reprint polocy. If reproduced, please indicate source
BY 水蓝
!