changing the speed of motion
I'm a beginner in Processing and here is my problem.
I want to prepare a short animation that later on I'll transform into a movie.
This movie will serve as a stimulus in my research.
I want lines that appear at some point of my animation to move smoothly with a constant speed.
My question is as follows:
why change to the magnitude of the frame rate does not allow me to speed up the lines movement?
if I cannot achieve this by using the frameRate, how can I change the speed of lines so they move slower or faster but with the same speed and smoothly?
I'll be very grateful for help
Piotr
here is my code
Rect[] rects = new Rect[10000] ;
int n=-3000;
void setup() {
frameRate(80);
size(1280,1024);
smooth();
for (int i = 0; i < rects.length; i++) {
rects[i] = new Rect(color (0,0,0), n, 0, 1);
n=n+30;
}
}
void draw() {
saveFrame("output/frames####.png");
background(180,180,180);
fill (0, 0, 0);
noStroke();
ellipse (640,512, 10, 10);
int passedTime_1 = millis() - 3000;
if (passedTime_1 >= 0) {
background(180,180,180);
for (int i = 0; i < rects.length; i++) {
rects[i].move();
rects[i].display();
}
fill (180,180,180);
noStroke();
rect (0, 0, 1280, 432);
rect (0, 592, 1280, 600);
rect (0, 0, 230, 1300);
rect (410, 0, 1200, 1300);
fill (0, 0, 0);
noStroke();
ellipse (640,512, 10, 10);
}
int passedTime_2 = millis()- 13000;
if (passedTime_2 >= 0) {
background(180,180,180);
}
int passedTime_3 = millis()- 18000;
if (passedTime_3 >= 0) {
exit ();
}
saveFrame("output.png");
}
class Rect {
color c;
float xpos;
float ypos;
float xspeed;
Rect(color c_, float xpos_, float ypos_, float xspeed_) {
c = c_;
xpos = xpos_;
ypos = ypos_;
xspeed = xspeed_;
}
void display() {
stroke(0);
fill(c);
rect(xpos,ypos,10,1030);
}
void move() {
xpos = xpos + xspeed;
//if (xpos > 490) {
//xpos=320;
//}
}
}