Pixel-Composer/scripts/node_outline/node_outline.gml

73 lines
2.7 KiB
Plaintext
Raw Normal View History

2022-12-13 09:20:36 +01:00
function Node_Outline(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constructor {
2022-01-13 05:24:03 +01:00
name = "Outline";
2022-12-21 02:30:23 +01:00
shader = sh_outline;
uniform_dim = shader_get_uniform(shader, "dimension");
uniform_border_size = shader_get_uniform(shader, "borderSize");
uniform_border_color = shader_get_uniform(shader, "borderColor");
2022-01-13 05:24:03 +01:00
2022-12-21 02:30:23 +01:00
uniform_blend = shader_get_uniform(shader, "is_blend");
uniform_blend_alpha = shader_get_uniform(shader, "blend_alpha");
2022-01-13 05:24:03 +01:00
2022-12-21 02:30:23 +01:00
uniform_side = shader_get_uniform(shader, "side");
uniform_aa = shader_get_uniform(shader, "is_aa");
2022-01-13 05:24:03 +01:00
2022-12-21 02:30:23 +01:00
uniform_out_only = shader_get_uniform(shader, "outline_only");
2022-01-13 05:24:03 +01:00
inputs[| 0] = nodeValue(0, "Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
2022-09-23 13:28:42 +02:00
inputs[| 1] = nodeValue(1, "Width", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0);
2022-01-13 05:24:03 +01:00
inputs[| 2] = nodeValue(2, "Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
2022-01-19 03:05:13 +01:00
inputs[| 3] = nodeValue(3, "Blend", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, 0);
2022-01-13 05:24:03 +01:00
inputs[| 4] = nodeValue(4, "Blend alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider, [0, 1, 0.01]);
2022-09-23 13:28:42 +02:00
inputs[| 5] = nodeValue(5, "Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1)
2022-01-19 03:05:13 +01:00
.setDisplay(VALUE_DISPLAY.enum_button, ["Inside", "Outside"]);
2022-01-13 05:24:03 +01:00
2022-01-19 03:05:13 +01:00
inputs[| 6] = nodeValue(6, "Anti alising", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, 0);
2022-01-13 05:24:03 +01:00
2022-09-21 06:09:40 +02:00
outputs[| 0] = nodeValue(0, "Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, PIXEL_SURFACE);
outputs[| 1] = nodeValue(1, "Outline", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, PIXEL_SURFACE);
2022-01-13 05:24:03 +01:00
2022-01-18 05:31:19 +01:00
static process_data = function(_outSurf, _data, _output_index) {
2022-01-13 05:24:03 +01:00
var ww = surface_get_width(_data[0]);
var hh = surface_get_height(_data[0]);
var wd = _data[1];
var cl = _data[2];
var blend = _data[3];
var alpha = _data[4];
var side = _data[5];
var aa = _data[6];
surface_set_target(_outSurf);
draw_clear_alpha(0, 0);
2022-12-27 04:00:50 +01:00
BLEND_OVER
2022-01-13 05:24:03 +01:00
2022-12-21 02:30:23 +01:00
shader_set(shader);
2022-01-13 05:24:03 +01:00
shader_set_uniform_f_array(uniform_dim, [ww, hh]);
shader_set_uniform_f(uniform_border_size, wd);
shader_set_uniform_f_array(uniform_border_color, [color_get_red(cl) / 255, color_get_green(cl) / 255, color_get_blue(cl) / 255, 1.0]);
shader_set_uniform_i(uniform_side, side);
shader_set_uniform_i(uniform_aa, aa);
shader_set_uniform_i(uniform_out_only, _output_index);
shader_set_uniform_i(uniform_blend, blend);
shader_set_uniform_f(uniform_blend_alpha, alpha);
draw_surface_safe(_data[0], 0, 0);
shader_reset();
BLEND_NORMAL
surface_reset_target();
2022-12-27 04:00:50 +01:00
return _outSurf;
2022-01-13 05:24:03 +01:00
}
2022-01-18 05:31:19 +01:00
static step = function() {
2022-01-13 05:24:03 +01:00
var blend = inputs[| 3].getValue();
2022-01-19 06:11:17 +01:00
inputs[| 4].setVisible(blend);
2022-01-13 05:24:03 +01:00
}
}