mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-14 06:23:55 +01:00
36 lines
1.1 KiB
Plaintext
36 lines
1.1 KiB
Plaintext
function Node_Atlas_Draw(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|
name = "Draw Atlas";
|
|
previewable = true;
|
|
|
|
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
inputs[| 1] = nodeValue("Atlas", self, JUNCTION_CONNECT.input, VALUE_TYPE.atlas, noone)
|
|
.setVisible(true, true);
|
|
|
|
outputs[| 0] = nodeValue("Surface", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
|
|
|
attribute_interpolation(true);
|
|
|
|
static update = function(frame = PROJECT.animator.current_frame) {
|
|
var dim = inputs[| 0].getValue();
|
|
var atl = inputs[| 1].getValue();
|
|
|
|
if(atl == noone) return;
|
|
if(is_array(atl) && array_length(atl) == 0) return;
|
|
|
|
if(!is_array(atl))
|
|
atl = [ atl ];
|
|
|
|
var outSurf = outputs[| 0].getValue();
|
|
outSurf = surface_verify(outSurf, dim[0], dim[1]);
|
|
outputs[| 0].setValue(outSurf);
|
|
|
|
surface_set_shader(outSurf,,, BLEND.alpha);
|
|
for( var i = 0, n = array_length(atl); i < n; i++ ) {
|
|
shader_set_interpolation(atl[i].surface.get())
|
|
atl[i].draw();
|
|
}
|
|
surface_reset_shader();
|
|
}
|
|
} |