Answer the question
In order to leave comments, you need to log in
Cycle from one to zero and back?
I make an animation when the element moves to one side and repels from it and returns, etc. infinite...
I can't implement the change of values on the border,
[1, 0.9, 0.8, ..., 0.2, 0.1, 0, 0.1, 0.2, ...1..0....
Answer the question
In order to leave comments, you need to log in
Brought you the metacode.
start = 0 // откуда вы начинаете
stop = 1 // куда вы движетесь
step = 0.1 // шаг, с которым вы движетесь
position = 0 // ваше текущее положение
while (true) { // чтобы анимация всегда повторялась, цикл должен быть вечным
position = position + step // приращиваем наш шаг
if (position == start || position == stop) {
// как только мы достигаем границы
// меняем знак шага, то есть меняем направление движения
step = -step
}
}
Discover the operation of taking the remainder of the division (mod), with the help of this operation it is achieved twice. Example .
The first thought is this:
while(true){
showToOne();
showToZero();
}
void showToOne(){
//
}
void showToZero(){
//
}
while True:
for i in range(0, 1.1, 0.1):
print(i)
for i in range(1, -0.1, -0.1):
print(i)
while(true) y=0,5+0,5*F(x++);
where F(t) - any periodic function that defines the animation,
0.5+0.5*F(t) - offset for the range [0;1].
For example, pendulum swings have a sinusoidal animation F(t) = Sin(t);
uniform shift per step - triangular shape of the animation curve.
List of the most common forms of curved animations (transitions): https://ru.wikipedia.org/wiki/waveform .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question