2023-02-28 09:43:01 +01:00
|
|
|
function Node_Gradient_Points(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2023-01-25 06:49:00 +01:00
|
|
|
name = "4 Points Gradient";
|
2022-12-13 14:11:39 +01:00
|
|
|
|
|
|
|
shader = sh_gradient_points;
|
|
|
|
uniform_dim = shader_get_uniform(shader, "dimension");
|
|
|
|
uniform_cen = shader_get_uniform(shader, "center");
|
|
|
|
uniform_col = shader_get_uniform(shader, "color");
|
|
|
|
|
2023-07-21 12:40:20 +02:00
|
|
|
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
|
2022-12-13 14:11:39 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 1] = nodeValue("Center 1", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] )
|
2022-12-27 04:00:50 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector)
|
2022-12-27 13:30:02 +01:00
|
|
|
.setUnitRef(function(index) { return getDimension(index); });
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 2] = nodeValue("Color 1", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white );
|
2022-12-13 14:11:39 +01:00
|
|
|
|
2023-07-21 12:40:20 +02:00
|
|
|
inputs[| 3] = nodeValue("Center 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ DEF_SURF_W, 0 ] )
|
2022-12-27 04:00:50 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector)
|
2022-12-27 13:30:02 +01:00
|
|
|
.setUnitRef(function(index) { return getDimension(index); });
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 4] = nodeValue("Color 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white );
|
2022-12-13 14:11:39 +01:00
|
|
|
|
2023-07-21 12:40:20 +02:00
|
|
|
inputs[| 5] = nodeValue("Center 3", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, DEF_SURF_H ] )
|
2022-12-27 04:00:50 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector)
|
2022-12-27 13:30:02 +01:00
|
|
|
.setUnitRef(function(index) { return getDimension(index); });
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 6] = nodeValue("Color 3", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white );
|
2022-12-13 14:11:39 +01:00
|
|
|
|
2023-07-21 12:40:20 +02:00
|
|
|
inputs[| 7] = nodeValue("Center 4", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, DEF_SURF )
|
2022-12-27 04:00:50 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector)
|
2022-12-27 13:30:02 +01:00
|
|
|
.setUnitRef(function(index) { return getDimension(index); });
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 8] = nodeValue("Color 4", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white );
|
2022-12-13 14:11:39 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 9] = nodeValue("Use palette", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
|
|
|
|
|
2023-07-21 12:40:20 +02:00
|
|
|
inputs[| 10] = nodeValue("Palette", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, DEF_PALETTE )
|
2023-02-14 05:32:32 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.palette);
|
|
|
|
|
|
|
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
2022-12-13 14:11:39 +01:00
|
|
|
|
|
|
|
input_display_list = [
|
2023-02-14 05:32:32 +01:00
|
|
|
["Output", true], 0,
|
2022-12-13 14:11:39 +01:00
|
|
|
["Positions", false], 1, 3, 5, 7,
|
2023-02-14 05:32:32 +01:00
|
|
|
["Colors", false], 9, 10, 2, 4, 6, 8,
|
2022-12-13 14:11:39 +01:00
|
|
|
];
|
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
attribute_surface_depth();
|
|
|
|
|
2022-12-19 13:35:30 +01:00
|
|
|
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
|
|
|
if(inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
|
|
|
|
if(inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
|
|
|
|
if(inputs[| 5].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
|
|
|
|
if(inputs[| 7].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny)) active = false;
|
2022-12-13 14:11:39 +01:00
|
|
|
}
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
static step = function() {
|
|
|
|
var _usePal = inputs[| 9].getValue();
|
|
|
|
|
|
|
|
inputs[| 10].setVisible(_usePal, _usePal);
|
|
|
|
|
|
|
|
inputs[| 2].setVisible(!_usePal, !_usePal);
|
|
|
|
inputs[| 4].setVisible(!_usePal, !_usePal);
|
|
|
|
inputs[| 6].setVisible(!_usePal, !_usePal);
|
|
|
|
inputs[| 8].setVisible(!_usePal, !_usePal);
|
|
|
|
}
|
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
static process_data = function(_outSurf, _data, _output_index, _array_index) {
|
2022-12-22 03:09:55 +01:00
|
|
|
var _dim = _data[0];
|
2022-12-13 14:11:39 +01:00
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
|
2023-02-14 05:32:32 +01:00
|
|
|
|
|
|
|
var _usePal = _data[9];
|
|
|
|
var _pal = _data[10];
|
|
|
|
|
2022-12-22 03:09:55 +01:00
|
|
|
var _1cen = _data[1];
|
|
|
|
var _1col = _data[2];
|
|
|
|
var _2cen = _data[3];
|
|
|
|
var _2col = _data[4];
|
|
|
|
var _3cen = _data[5];
|
|
|
|
var _3col = _data[6];
|
|
|
|
var _4cen = _data[7];
|
|
|
|
var _4col = _data[8];
|
2022-12-13 14:11:39 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
var colArr = [];
|
|
|
|
|
|
|
|
if(_usePal) {
|
|
|
|
for( var i = 0; i < 4; i++ )
|
|
|
|
colArr = array_append(colArr, colorArrayFromReal(array_safe_get(_pal, i, c_black)));
|
|
|
|
} else
|
|
|
|
colArr = array_merge(colorArrayFromReal(_1col), colorArrayFromReal(_2col), colorArrayFromReal(_3col), colorArrayFromReal(_4col))
|
|
|
|
|
2022-12-13 14:11:39 +01:00
|
|
|
surface_set_target(_outSurf);
|
2023-03-19 09:17:39 +01:00
|
|
|
DRAW_CLEAR
|
2022-12-13 14:11:39 +01:00
|
|
|
shader_set(shader);
|
2023-02-14 05:32:32 +01:00
|
|
|
shader_set_uniform_f_array_safe(uniform_dim, [_dim[0], _dim[1]]);
|
|
|
|
shader_set_uniform_f_array_safe(uniform_cen, array_merge(_1cen, _2cen, _3cen, _4cen));
|
|
|
|
shader_set_uniform_f_array_safe(uniform_col, colArr);
|
2022-12-13 14:11:39 +01:00
|
|
|
|
|
|
|
draw_sprite_stretched_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], c_white, 1);
|
|
|
|
shader_reset();
|
|
|
|
surface_reset_target();
|
2022-12-22 03:09:55 +01:00
|
|
|
|
|
|
|
return _outSurf;
|
2022-12-13 14:11:39 +01:00
|
|
|
}
|
|
|
|
}
|