Pixel-Composer/scripts/node_pb_draw/node_pb_draw.gml

35 lines
1.1 KiB
Text
Raw Normal View History

2023-07-21 12:40:20 +02:00
function Node_PB_Draw(_x, _y, _group = noone) : Node_PB(_x, _y, _group) constructor {
name = "PB Draw";
2024-08-08 06:57:51 +02:00
inputs[0] = nodeValue("pBox", self, JUNCTION_CONNECT.input, VALUE_TYPE.pbBox, noone )
2023-07-21 12:40:20 +02:00
.setVisible(true, true);
2024-08-08 06:57:51 +02:00
inputs[1] = nodeValue_Color("Color", self, c_white );
2023-07-21 12:40:20 +02:00
2024-08-08 06:57:51 +02:00
inputs[2] = nodeValue_Bool("Apply Mask", self, true );
2023-07-21 12:40:20 +02:00
2024-08-08 06:57:51 +02:00
outputs[0] = nodeValue_Output("pBox", self, VALUE_TYPE.pbBox, noone);
2023-08-10 11:51:16 +02:00
static getGraphPreviewSurface = function() {
2024-08-08 06:57:51 +02:00
var _nbox = outputs[0].getValue();
2023-08-10 11:51:16 +02:00
if(_nbox == noone) return noone;
2023-10-12 07:07:24 +02:00
if(is_array(_nbox)) {
if(array_empty(_nbox)) return noone;
_nbox = _nbox[0];
}
2023-08-10 11:51:16 +02:00
return _nbox.content;
}
2023-07-23 20:21:35 +02:00
}
#macro PB_DRAW_CREATE_MASK _nbox.mask = surface_verify(_nbox.mask, _nbox.w, _nbox.h); \
surface_set_shader(_nbox.mask, sh_pb_to_mask); \
draw_surface_safe(_nbox.content); \
2023-07-23 20:21:35 +02:00
surface_reset_shader();
#macro PB_DRAW_APPLY_MASK if(_mask) { \
BLEND_MULTIPLY \
if(is_surface(_pbox.mask)) \
draw_surface_safe(_pbox.mask); \
2023-07-23 20:21:35 +02:00
BLEND_NORMAL \
}