Pixel-Composer/scripts/node_cross_section/node_cross_section.gml

73 lines
1.9 KiB
Text
Raw Normal View History

2024-05-19 15:11:45 +02:00
function Node_Cross_Section(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
2024-06-20 08:55:04 +02:00
name = "Draw Cross Section";
2024-05-19 15:11:45 +02:00
2024-08-18 06:16:20 +02:00
newInput(0, nodeValue_Surface("Surface in", self));
2024-05-19 15:11:45 +02:00
2024-08-18 06:16:20 +02:00
newInput(1, nodeValue_Enum_Button("Axis", self, 0 , [ "X", "Y" ]));
2024-05-20 05:16:05 +02:00
2024-08-18 09:13:41 +02:00
newInput(2, nodeValue_Float("Position", self, 0 ))
2024-05-20 05:16:05 +02:00
.setDisplay(VALUE_DISPLAY.slider);
2024-08-18 06:16:20 +02:00
newInput(3, nodeValue_Bool("Anti Aliasing", self, false ));
2024-05-20 05:16:05 +02:00
2024-08-18 06:16:20 +02:00
newInput(4, nodeValue_Enum_Button("Mode", self, 0 , [ "BW", "Colored" ]));
2024-05-20 05:16:05 +02:00
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone ));
2024-05-19 15:11:45 +02:00
input_display_list = [
2024-05-20 05:16:05 +02:00
["Surfaces", false], 0,
["Axis", false], 1, 2,
["Output", false], 4, 3,
2024-05-19 15:11:45 +02:00
];
attribute_surface_depth();
2024-05-20 05:16:05 +02:00
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, params) { #region
PROCESSOR_OVERLAY_CHECK
var _surf = getSingleValue(0);
var _iaxs = getSingleValue(1);
var _posi = getSingleValue(2);
var _dim = surface_get_dimension(_surf);
if(_iaxs == 0) {
var _x0 = _x;
var _y0 = _y + _posi * _dim[1] * _s;
var _x1 = _x + _dim[0] * _s;
var _y1 = _y0;
} else {
var _x0 = _x + _posi * _dim[0] * _s;
var _y0 = _y;
var _x1 = _x0;
var _y1 = _y + _dim[1] * _s;
}
draw_set_color(COLORS._main_accent);
draw_line(_x0, _y0, _x1, _y1);
}
2024-05-19 15:11:45 +02:00
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _surf = _data[0];
2024-05-20 05:16:05 +02:00
var _iaxs = _data[1];
var _posi = _data[2];
var _aa = _data[3];
var _mode = _data[4];
2024-05-19 15:11:45 +02:00
2024-05-20 05:16:05 +02:00
var _dim = surface_get_dimension(_surf);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1]);
2024-05-19 15:11:45 +02:00
2024-05-20 05:16:05 +02:00
surface_set_shader(_outSurf, sh_cross_section);
shader_set_f("dimension", _dim);
shader_set_i("iAxis", _iaxs);
shader_set_f("position", _posi);
shader_set_i("aa", _aa);
shader_set_i("mode", _mode);
draw_surface_safe(_surf);
2024-05-20 05:16:05 +02:00
surface_reset_shader();
2024-05-19 15:11:45 +02:00
return _outSurf;
}
}