Pixel-Composer/scripts/lerp_float/lerp_float.gml

37 lines
1.1 KiB
Text
Raw Normal View History

2023-08-17 16:56:54 +02:00
function lerp_float(from, to, speed, pre = 0.01) {
2022-11-03 11:44:49 +01:00
if(fps < 15) return to;
2022-01-13 05:24:03 +01:00
2023-08-17 16:56:54 +02:00
if(abs(from - to) < pre) return to;
return from + (to - from) * (1 - power(1 - 1 / speed, delta_time / 1000000 * game_get_speed(gamespeed_fps)));
2022-01-13 05:24:03 +01:00
}
function lerp_linear(from, to, speed) {
2023-08-17 16:56:54 +02:00
if(abs(from - to) < speed) return to;
return from + sign(to - from) * speed;
2022-01-13 05:24:03 +01:00
}
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;
2023-05-08 10:50:42 +02:00
return from + angle_difference(to, from) * (1 - power(1 - 1 / speed, delta_time / 1000000 * game_get_speed(gamespeed_fps)));
2022-01-13 05:24:03 +01:00
}
function lerp_angle_linear(from, to, speed) {
if(abs(angle_difference(to, from)) < speed) return to;
return from + sign(angle_difference(to, from)) * speed;
2023-06-26 18:55:41 +02:00
}
function lerp_float_angle(from, to, ratio) {
return from + angle_difference(to, from) * ratio;
2023-08-17 16:56:54 +02:00
}
function lerp_color(from, to, ratio) {
if(abs(from - to) < 1) return to;
return merge_color(from, to, ratio);
2024-06-08 06:31:21 +02:00
}
function lerp_invert(val, from, to) { return (val - from) / (to - from); }