Simple animation question
in
Programming Questions
•
2 years ago
Hi , i need to make something very easy , but i cant find a way.
I just need to make a program that each 5 seconds it calls a function that makes it rotate from one angle to another then the next time the function is called it rotate back to its orignial position.
So : Each 5 seconds it rotates from 0 to 60 angle and then the next time (after 5 seconds again) it rotates back to 0, after 5 secnds it rotates again from 0 to 60 and so on.....
My question should be how can i make a function that everytime it is called can make an interpolation from one point to another?
how can i do this?
in the following code each 5 seconds it add just one value, but i would like that instead of adding just one value, it can interpolate from 0 to 70
any idea?
I just need to make a program that each 5 seconds it calls a function that makes it rotate from one angle to another then the next time the function is called it rotate back to its orignial position.
So : Each 5 seconds it rotates from 0 to 60 angle and then the next time (after 5 seconds again) it rotates back to 0, after 5 secnds it rotates again from 0 to 60 and so on.....
My question should be how can i make a function that everytime it is called can make an interpolation from one point to another?
how can i do this?
in the following code each 5 seconds it add just one value, but i would like that instead of adding just one value, it can interpolate from 0 to 70
any idea?
float rotate_variable = 0 ;
void setup()
{
size(300, 300, P3D);
}
void draw()
{
float m = millis();
background(250, 0 , 0);
// float m = millis();
if (m % 1000 == 0) {
funcion_rota( );
};
//lerp
translate(width/2, height/2);
rotate(radians(rotate_variable));
rect(-26, -26, 52, 52);
}
void funcion_rota() {
rotate_variable = rotate_variable + 1;
}
1
