Pixel-Composer/scripts/node_array_range/node_array_range.gml

44 lines
1.4 KiB
Text
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Array_Range(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
2023-01-25 06:49:00 +01:00
name = "Array Range";
2022-12-16 09:18:09 +01:00
previewable = false;
w = 96;
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, []);
static update = function(frame = ANIMATOR.current_frame) {
2022-12-16 09:18:09 +01:00
var st = inputs[| 0].getValue();
var ed = inputs[| 1].getValue();
var step = inputs[| 2].getValue();
var arr = [];
if((step > 0 && st <= ed) || (step < 0 && st >= ed)) {
for( var i = st; i <= ed; i += step )
array_push(arr, i);
}
outputs[| 0].setValue(arr);
}
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-01-25 06:49:00 +01:00
draw_set_text(f_p0, fa_center, fa_center, COLORS._main_text);
var str = inputs[| 0].getValue();
var edd = inputs[| 1].getValue();
var stp = inputs[| 2].getValue();
var str = "[" + string(str) + ", " + string(str + stp) + ", ... ," + string(edd) + "]";
var bbox = drawGetBbox(xx, yy, _s);
var ss = string_scale(str, bbox.w, bbox.h);
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
}
2022-12-16 09:18:09 +01:00
}