2023-10-08 10:46:13 +02:00
|
|
|
function Node_Array_Composite(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
2024-03-28 14:18:02 +01:00
|
|
|
name = "Array Composite";
|
|
|
|
setDimension(96, 32 + 24);
|
2023-10-08 10:46:13 +02:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[0] = nodeValue_Float("Array", self, [])
|
2023-10-08 10:46:13 +02:00
|
|
|
.setArrayDepth(1)
|
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[1] = nodeValue_Float("Compose", self, [])
|
2023-10-08 10:46:13 +02:00
|
|
|
.setArrayDepth(1)
|
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0] = nodeValue_Output("Array", self, VALUE_TYPE.float, 0)
|
2023-10-08 10:46:13 +02:00
|
|
|
.setArrayDepth(1);
|
|
|
|
|
|
|
|
static composite = function(arr, com) {
|
|
|
|
__tmp_com = com;
|
|
|
|
__tmp_len = array_length(com);
|
|
|
|
|
|
|
|
return array_map(arr, function(val, ind) {
|
|
|
|
var ret = array_create(__tmp_len);
|
|
|
|
|
|
|
|
for( var i = 0; i < __tmp_len; i++ )
|
|
|
|
ret[i] = __tmp_com[i] * val;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-10-09 16:07:33 +02:00
|
|
|
static update = function(frame = CURRENT_FRAME) {
|
2023-10-08 10:46:13 +02:00
|
|
|
var _arr = getInputData(0);
|
|
|
|
var _ker = getInputData(1);
|
|
|
|
|
2023-10-10 10:40:36 +02:00
|
|
|
|
|
|
|
if(!is_array(_arr) || !is_array(_ker)) return;
|
2023-10-08 10:46:13 +02:00
|
|
|
if(array_empty(_arr) || array_empty(_ker)) return;
|
|
|
|
|
|
|
|
var res;
|
|
|
|
|
|
|
|
if(is_array(_arr[0])) {
|
|
|
|
for( var i = 0, n = array_length(_arr); i < n; i++ )
|
|
|
|
res[i] = composite(_arr[i], _ker);
|
|
|
|
} else
|
|
|
|
res = composite(_arr, _ker);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setValue(res);
|
2023-10-08 10:46:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
draw_sprite_fit(s_node_array_composite, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
|
|
|
}
|
|
|
|
}
|