Pixel-Composer/scripts/angle_functions/angle_functions.gml

34 lines
1.3 KiB
Text
Raw Normal View History

2024-08-25 10:18:22 +02:00
function angle_random_eval(range, seed = random_get_seed()) {
2024-01-24 06:19:34 +01:00
if(is_real(range)) return range;
2023-09-11 16:08:58 +02:00
2023-09-19 12:53:24 +02:00
if(array_empty(range)) return 0;
2024-01-24 06:19:34 +01:00
var _l = array_length(range);
2023-09-19 12:53:24 +02:00
2024-01-24 06:19:34 +01:00
if(_l < 2)
2023-09-19 12:53:24 +02:00
return range[0]
2024-01-24 06:19:34 +01:00
else if(_l == 2)
2024-08-25 10:18:22 +02:00
return random_range_seed(range[0], range[1], seed);
2024-01-24 06:19:34 +01:00
else if(_l > 2) {
2023-09-11 16:08:58 +02:00
switch(range[0]) {
2024-08-25 10:18:22 +02:00
case 0 : return random_range_seed(range[1], range[2], seed);
case 1 : return random_range_seed(range[1] - range[2], range[1] + range[2], seed);
case 2 : return choose(random_range_seed(range[1], range[2], seed), random_range_seed(range[3], range[4], seed));
case 3 : return choose(random_range_seed(range[1] - range[3], range[1] + range[3], seed), random_range_seed(range[2] - range[3], range[2] + range[3], seed));
2023-09-11 16:08:58 +02:00
}
}
2024-03-31 05:36:11 +02:00
return array_safe_get_fast(range, 0);
2024-01-24 06:19:34 +01:00
}
2024-08-25 10:18:22 +02:00
function angle_random_eval_fast(range, seed = random_get_seed()) {
2024-01-24 06:19:34 +01:00
switch(range[0]) {
2024-08-25 10:18:22 +02:00
case 0 : return random_range_seed(range[1], range[2], seed);
case 1 : return random_range_seed(range[1] - range[2], range[1] + range[2], seed);
case 2 : return choose(random_range_seed(range[1], range[2], seed), random_range_seed(range[3], range[4], seed));
case 3 : return choose(random_range_seed(range[1] - range[3], range[1] + range[3], seed), random_range_seed(range[2] - range[3], range[2] + range[3], seed));
2024-01-24 06:19:34 +01:00
}
return 0;
2023-09-11 16:08:58 +02:00
}