mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-10 20:45:35 +01:00
80 lines
2.4 KiB
Plaintext
80 lines
2.4 KiB
Plaintext
function Node_De_Stray(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
|
name = "De-Stray";
|
|
|
|
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
|
|
|
inputs[| 1] = nodeValue("Tolerance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
|
|
|
inputs[| 2] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
|
active_index = 2;
|
|
|
|
inputs[| 3] = nodeValue("Iteration", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 2)
|
|
|
|
inputs[| 4] = nodeValue("Strictness", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
|
.setDisplay(VALUE_DISPLAY.enum_button, [ "Low", "High", "Stray-only" ]);
|
|
|
|
inputs[| 5] = nodeValue("Mask", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
|
|
|
inputs[| 6] = nodeValue("Mix", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
|
|
|
__init_mask_modifier(5); // inputs 7, 8,
|
|
|
|
inputs[| 9] = nodeValue("Fill Empty", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
|
|
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
|
|
|
input_display_list = [ 2,
|
|
["Surfaces", true], 0, 5, 6, 7, 8,
|
|
["Effect", false], 4, 1, 3, 9,
|
|
]
|
|
|
|
attribute_surface_depth();
|
|
|
|
temp_surface = [ noone, noone ];
|
|
|
|
static step = function() { #region
|
|
__step_mask_modifier();
|
|
} #endregion
|
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
|
var surf = _data[0];
|
|
var _tol = _data[1];
|
|
var _itr = _data[3];
|
|
var _str = _data[4];
|
|
var _fil = _data[9];
|
|
|
|
var _sw = surface_get_width_safe(surf);
|
|
var _sh = surface_get_height_safe(surf);
|
|
|
|
for( var i = 0; i < 2; i++ ) temp_surface[i] = surface_verify(temp_surface[i], _sw, _sh);
|
|
|
|
var _bg = 0;
|
|
surface_set_shader(temp_surface[1]);
|
|
draw_surface_safe(surf);
|
|
surface_reset_shader();
|
|
|
|
repeat(_itr) {
|
|
surface_set_shader(temp_surface[_bg], sh_de_stray);
|
|
shader_set_f("dimension", _sw, _sh);
|
|
shader_set_f("tolerance", _tol);
|
|
shader_set_i("strict", _str);
|
|
shader_set_i("fill", _fil);
|
|
|
|
draw_surface_safe(temp_surface[!_bg]);
|
|
surface_reset_shader();
|
|
|
|
_bg = !_bg;
|
|
}
|
|
|
|
surface_set_shader(_outSurf);
|
|
draw_surface_safe(temp_surface[!_bg]);
|
|
surface_reset_shader();
|
|
|
|
__process_mask_modifier(_data);
|
|
_outSurf = mask_apply(_data[0], _outSurf, _data[5], _data[6]);
|
|
|
|
return _outSurf;
|
|
} #endregion
|
|
} |