Pixel-Composer/scripts/node_surface_data/node_surface_data.gml

35 lines
1.0 KiB
Plaintext
Raw Normal View History

2022-12-13 09:20:36 +01:00
function Node_Surface_data(_x, _y, _group = -1) : Node(_x, _y, _group) constructor {
2022-01-13 05:24:03 +01:00
name = "Surface data";
2022-11-18 03:20:31 +01:00
color = COLORS.node_blend_number;
2022-01-13 05:24:03 +01:00
previewable = false;
inputs[| 0] = nodeValue(0, "Surface", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
outputs[| 0] = nodeValue(0, "Dimension", self, JUNCTION_CONNECT.output, VALUE_TYPE.integer, [ 1, 1 ])
.setDisplay(VALUE_DISPLAY.vector);
outputs[| 1] = nodeValue(1, "Array length", self, JUNCTION_CONNECT.output, VALUE_TYPE.integer, 0);
2023-01-17 08:11:55 +01:00
2022-01-13 05:24:03 +01:00
w = 96;
2022-01-18 05:31:19 +01:00
static update = function() {
2022-01-13 05:24:03 +01:00
var _insurf = inputs[| 0].getValue();
if(is_array(_insurf)) {
var len = array_length(_insurf);
var _dim = array_create(len);
for( var i = 0; i < len; i++ ) {
2022-01-13 05:24:03 +01:00
_dim[i][0] = surface_get_width(_insurf[i]);
_dim[i][1] = surface_get_height(_insurf[i]);
}
outputs[| 0].setValue(_dim);
outputs[| 1].setValue(len);
return;
}
if(!_insurf || !surface_exists(_insurf)) return;
outputs[| 0].setValue([ surface_get_width(_insurf), surface_get_height(_insurf) ]);
}
}