Pixel-Composer/scripts/random_function/random_function.gml
2022-01-13 11:24:03 +07:00

18 lines
No EOL
462 B
Text

function getWiggle(_min, _max, _fmin, _fmax, _time, seed_shift = 0) {
random_set_seed(GLOBAL_SEED + seed_shift);
var _x0 = random_range(_min, _max);
var _x1 = random_range(_min, _max);
var _t_next = 0, _t_prev = 0;
while(_t_next < _time) {
_x0 = _x1;
_x1 = random_range(_min, _max);
_t_prev = _t_next;
_t_next = _t_prev + irandom_range(_fmin, _fmax);
}
var _val = lerp(_x0, _x1, (_time - _t_prev) / (_t_next - _t_prev));
return _val;
}