2022-01-13 05:24:03 +01:00
|
|
|
/// @description lerp_float
|
|
|
|
/// @param from
|
|
|
|
/// @param to
|
|
|
|
/// @param speed
|
|
|
|
/// @param *precision
|
|
|
|
function lerp_float(from, to, speed) {
|
2022-11-03 11:44:49 +01:00
|
|
|
if(fps < 15) return to;
|
2022-01-13 05:24:03 +01:00
|
|
|
var pre = argument_count > 3? argument[3] : 0.01;
|
|
|
|
|
|
|
|
if(abs(from - to) < pre)
|
|
|
|
return to;
|
|
|
|
else
|
2022-12-10 05:06:01 +01:00
|
|
|
return from + (to - from) * (1 - power(1 - 1 / speed, delta_time / 1000000 * room_speed));
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function lerp_linear(from, to, speed) {
|
2022-11-03 11:44:49 +01:00
|
|
|
if(fps < 15) return to;
|
2022-01-13 05:24:03 +01:00
|
|
|
if(abs(from - to) < speed)
|
|
|
|
return to;
|
|
|
|
else
|
|
|
|
return from + sign(to - from) * speed;
|
|
|
|
}
|
|
|
|
|
2023-02-19 13:49:20 +01:00
|
|
|
function lerp_angle_direct(from, to, speed) {
|
|
|
|
return from + angle_difference(to, from) * speed;
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
function lerp_angle(from, to, speed) {
|
2022-11-03 11:44:49 +01:00
|
|
|
if(fps < 15) return to;
|
2022-12-10 05:06:01 +01:00
|
|
|
return from + angle_difference(to, from) * (1 - power(1 - 1 / speed, delta_time / 1000000 * room_speed));
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function lerp_angle_linear(from, to, speed) {
|
2022-11-03 11:44:49 +01:00
|
|
|
if(fps < 15) return to;
|
2022-01-13 05:24:03 +01:00
|
|
|
if(abs(angle_difference(to, from)) < speed) return to;
|
|
|
|
|
|
|
|
return from + sign(angle_difference(to, from)) * speed;
|
|
|
|
}
|