2024-07-11 08:35:32 +02:00
|
|
|
function Node_Array_Range(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2023-01-25 06:49:00 +01:00
|
|
|
name = "Array Range";
|
2024-05-02 12:13:35 +02:00
|
|
|
setDimension(96, 48);
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 0] = nodeValue("Start", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
|
|
|
.rejectArray();
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 1] = nodeValue("End", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 10)
|
|
|
|
.rejectArray();
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 2] = nodeValue("Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
|
|
|
.rejectArray();
|
|
|
|
|
|
|
|
outputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, []);
|
|
|
|
|
2024-07-11 08:35:32 +02:00
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
|
|
|
var st = _data[0];
|
|
|
|
var ed = _data[1];
|
|
|
|
var stp = _data[2];
|
2024-01-22 14:23:35 +01:00
|
|
|
var arr = [];
|
2022-12-16 09:18:09 +01:00
|
|
|
|
2024-01-22 14:23:35 +01:00
|
|
|
if(st == ed) {
|
|
|
|
arr = array_create(stp, st);
|
|
|
|
} else if(sign(stp) == sign(ed - st)) {
|
|
|
|
var _amo = floor(abs((ed - st) / stp));
|
|
|
|
|
|
|
|
for( var i = 0; i < _amo; i++ )
|
|
|
|
array_push(arr, st + i * stp);
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|
|
|
|
|
2024-07-11 08:35:32 +02:00
|
|
|
return arr;
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
2023-11-23 08:28:04 +01:00
|
|
|
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
2024-07-11 08:35:32 +02:00
|
|
|
var str = getSingleValue(0);
|
|
|
|
var edd = getSingleValue(1);
|
|
|
|
var stp = getSingleValue(2);
|
2024-01-22 14:23:35 +01:00
|
|
|
var arr = outputs[| 0].getValue();
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2024-01-22 14:23:35 +01:00
|
|
|
var str = "";
|
|
|
|
switch(array_length(arr)) {
|
|
|
|
case 0 : str = $"[]" break;
|
|
|
|
case 1 :
|
|
|
|
case 2 :
|
|
|
|
case 3 : str = $"{arr}" break;
|
|
|
|
|
|
|
|
default : str = $"[{arr[0]}, {arr[1]}, ..., {array_safe_get(arr, -1,, ARRAY_OVERFLOW.loop)}]"; break;
|
|
|
|
}
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
2024-07-11 08:35:32 +02:00
|
|
|
draw_text_bbox(bbox, str);
|
2023-01-25 06:49:00 +01:00
|
|
|
}
|
2022-12-16 09:18:09 +01:00
|
|
|
}
|