Hi Hi,
I would like to transform this program so that the movement created with the mouse can be followed but slower than in reality.
I would like to have this movement in slow motion, i.e. if I make some sort of circles at 1 rpm/s with the mouse, I would like to see the other points follow mouseX, mouseY at 0.5 rpm
Maybe we should save the point of mouseX mouseY and display them with time increased by two?
//https://processing.org/examples/follow3.html
float[] x = new float[20];
float[] y = new float[20];
float segLength = 18;
public void settings() {
size(600, 600, P3D);
}
void setup() {
strokeWeight(9);
stroke(255, 100);
}
void draw() {
background(0);
dragSegment(0, mouseX, mouseY);
for(int i=0; i<x.length-1; i++) {
dragSegment(i+1, x[i], y[i]);
}
}
void dragSegment(int i, float xin, float yin) {
float dx = xin - x[i];
float dy = yin - y[i];
float angle = atan2(dy, dx);
x[i] = xin - cos(angle) * segLength;
y[i] = yin - sin(angle) * segLength;
segment(x[i], y[i], angle);
}
void segment(float x, float y, float a) {
pushMatrix();
translate(x, y);
rotate(a);
line(0, 0, segLength, 0);
popMatrix();
}