Pixel-Composer/scripts/random_function/random_function.gml

30 lines
679 B
Plaintext
Raw Normal View History

2022-01-13 05:24:03 +01:00
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);
2022-09-21 06:09:40 +02:00
var _t_prev = 0;
var _t_next = irandom_range(_fmin, _fmax);
2022-01-13 05:24:03 +01:00
while(_t_next < _time) {
_x0 = _x1;
_x1 = random_range(_min, _max);
_t_prev = _t_next;
_t_next = _t_prev + irandom_range(_fmin, _fmax);
}
2022-09-21 06:09:40 +02:00
var t = (_time - _t_prev) / (_t_next - _t_prev);
t = -(cos(pi * t) - 1) / 2;
var _val = lerp(_x0, _x1, t);
2022-01-13 05:24:03 +01:00
return _val;
2022-01-19 03:05:13 +01:00
}
function generateUUID() {
randomize();
var uuid;
do {
uuid = irandom(1000000000);
} until(!ds_map_exists(NODE_MAP, uuid))
return uuid;
2022-01-13 05:24:03 +01:00
}