2023-02-28 09:43:01 +01:00
|
|
|
function Node_Gradient(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2023-01-25 06:49:00 +01:00
|
|
|
name = "Draw Gradient";
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-07-21 12:40:20 +02:00
|
|
|
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
|
2022-01-13 05:24:03 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
2024-01-09 03:39:40 +01:00
|
|
|
inputs[| 1] = nodeValue("Gradient", self, JUNCTION_CONNECT.input, VALUE_TYPE.gradient, new gradientObject([ c_black, c_white ]) );
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 2] = nodeValue("Type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
2022-01-19 03:05:13 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Linear", "Circular", "Radial" ]);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 3] = nodeValue("Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
2023-12-23 09:39:55 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.rotation)
|
|
|
|
.setMappable(10);
|
2022-01-18 05:31:19 +01:00
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
inputs[| 4] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, .5)
|
|
|
|
.setMappable(11);
|
2022-01-18 05:31:19 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 5] = nodeValue("Shift", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
2023-12-23 09:39:55 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider, { range: [-2, 2, 0.01] })
|
|
|
|
.setMappable(12);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-11-08 13:05:24 +01:00
|
|
|
inputs[| 6] = nodeValue("Center", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0.5, 0.5 ])
|
2022-12-27 04:00:50 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector)
|
2023-11-08 13:05:24 +01:00
|
|
|
.setUnitRef(function(index) { return getDimension(index); }, VALUE_UNIT.reference);
|
2022-01-18 05:31:19 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 7] = nodeValue("Loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 8] = nodeValue("Mask", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
2022-09-21 06:09:40 +02:00
|
|
|
|
2023-03-08 12:14:01 +01:00
|
|
|
inputs[| 9] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
2023-12-23 09:39:55 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 2, 0.01] })
|
|
|
|
.setMappable(13);
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
inputs[| 10] = nodeValueMap("Angle map", self);
|
|
|
|
|
|
|
|
inputs[| 11] = nodeValueMap("Radius map", self);
|
|
|
|
|
|
|
|
inputs[| 12] = nodeValueMap("Shift map", self);
|
|
|
|
|
|
|
|
inputs[| 13] = nodeValueMap("Scale map", self);
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2024-01-20 05:06:56 +01:00
|
|
|
inputs[| 14] = nodeValue("Uniform ratio", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
input_display_list = [
|
2022-09-21 06:09:40 +02:00
|
|
|
["Output", true], 0, 8,
|
2023-12-23 09:39:55 +01:00
|
|
|
["Gradient", false], 1, 5, 12, 9, 13, 7,
|
2024-01-20 05:06:56 +01:00
|
|
|
["Shape", false], 2, 3, 10, 4, 11, 6, 14,
|
2022-01-13 05:24:03 +01:00
|
|
|
];
|
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
attribute_surface_depth();
|
|
|
|
|
2024-01-20 05:06:56 +01:00
|
|
|
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
2022-12-19 13:35:30 +01:00
|
|
|
inputs[| 6].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
|
2024-01-20 05:06:56 +01:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
static step = function() { #region
|
2024-01-20 05:06:56 +01:00
|
|
|
var _typ = getInputData(2);
|
|
|
|
|
|
|
|
inputs[| 3].setVisible(_typ != 1);
|
|
|
|
inputs[| 4].setVisible(_typ == 1);
|
2024-01-21 10:21:38 +01:00
|
|
|
inputs[| 14].setVisible(_typ);
|
2024-01-20 05:06:56 +01:00
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
inputs[| 3].mappableStep();
|
|
|
|
inputs[| 4].mappableStep();
|
|
|
|
inputs[| 5].mappableStep();
|
|
|
|
inputs[| 9].mappableStep();
|
|
|
|
} #endregion
|
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
2022-12-22 03:09:55 +01:00
|
|
|
var _dim = _data[0];
|
|
|
|
var _gra = _data[1];
|
|
|
|
var _typ = _data[2];
|
|
|
|
var _cnt = _data[6];
|
|
|
|
var _lop = _data[7];
|
|
|
|
var _msk = _data[8];
|
2024-01-20 05:06:56 +01:00
|
|
|
var _uni = _data[14];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
|
2023-03-08 12:14:01 +01:00
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
surface_set_shader(_outSurf, sh_gradient);
|
|
|
|
_gra.shader_submit();
|
2022-01-14 02:44:58 +01:00
|
|
|
|
2024-01-20 05:06:56 +01:00
|
|
|
shader_set_f("dimension", _dim);
|
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
shader_set_i("gradient_loop", _lop);
|
|
|
|
shader_set_f("center", _cnt[0] / _dim[0], _cnt[1] / _dim[1]);
|
|
|
|
shader_set_i("type", _typ);
|
2024-01-20 05:06:56 +01:00
|
|
|
shader_set_i("uniAsp", _uni);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
shader_set_f_map("angle", _data[3], _data[10], inputs[| 3]);
|
|
|
|
shader_set_f_map("radius", _data[4], _data[11], inputs[| 4]);
|
|
|
|
shader_set_f_map("shift", _data[5], _data[12], inputs[| 5]);
|
|
|
|
shader_set_f_map("scale", _data[9], _data[13], inputs[| 9]);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
if(is_surface(_msk)) draw_surface_stretched_ext(_msk, 0, 0, _dim[0], _dim[1], c_white, 1);
|
|
|
|
else draw_sprite_stretched_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], c_white, 1);
|
|
|
|
surface_reset_shader();
|
2022-12-22 03:09:55 +01:00
|
|
|
|
|
|
|
return _outSurf;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|