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
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(0, nodeValue_Dimension(self));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(1, nodeValue_Gradient("Gradient", self, new gradientObject([ cola(c_black), cola(c_white) ])))
|
2024-01-22 10:26:25 +01:00
|
|
|
.setMappable(15);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-20 10:15:53 +02:00
|
|
|
newInput(2, nodeValue_Enum_Scroll("Type", self, 0, [ new scrollItem("Linear", s_node_gradient_type, 0),
|
|
|
|
new scrollItem("Circular", s_node_gradient_type, 1),
|
|
|
|
new scrollItem("Radial", s_node_gradient_type, 2) ]));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(3, nodeValue_Rotation("Angle", self, 0))
|
2023-12-23 09:39:55 +01:00
|
|
|
.setMappable(10);
|
2022-01-18 05:31:19 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(4, nodeValue_Float("Radius", self, .5))
|
2023-12-23 09:39:55 +01:00
|
|
|
.setMappable(11);
|
2022-01-18 05:31:19 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(5, nodeValue_Float("Shift", self, 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
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(6, nodeValue_Vec2("Center", self, [ 0.5, 0.5 ]))
|
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
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(7, nodeValue_Enum_Button("Loop", self, 0, [ "None", "Loop", "Pingpong" ]));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(8, nodeValue_Surface("Mask", self));
|
2022-09-21 06:09:40 +02:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(9, nodeValue_Float("Scale", self, 1))
|
2023-12-23 09:39:55 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 2, 0.01] })
|
|
|
|
.setMappable(13);
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(10, nodeValueMap("Angle map", self));
|
2023-12-23 09:39:55 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(11, nodeValueMap("Radius map", self));
|
2023-12-23 09:39:55 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(12, nodeValueMap("Shift map", self));
|
2023-12-23 09:39:55 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(13, nodeValueMap("Scale map", self));
|
2023-12-23 09:39:55 +01:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(14, nodeValue_Bool("Uniform ratio", self, true));
|
2024-01-20 05:06:56 +01:00
|
|
|
|
2024-01-22 10:26:25 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(15, nodeValueMap("Gradient map", self));
|
2024-01-22 10:26:25 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(16, nodeValueGradientRange("Gradient map range", self, inputs[1]));
|
2024-01-22 10:26:25 +01:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Surface out", self, 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,
|
2024-01-22 10:26:25 +01:00
|
|
|
["Gradient", false], 1, 15, 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-07-02 12:18:32 +02:00
|
|
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
2024-05-10 04:01:14 +02:00
|
|
|
PROCESSOR_OVERLAY_CHECK
|
2024-07-02 12:18:32 +02:00
|
|
|
var _hov = false;
|
2024-08-08 06:57:51 +02:00
|
|
|
var a = inputs[6].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); active &= !a; _hov |= a;
|
|
|
|
var a = inputs[16].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, current_data[0]); active &= !a; _hov |= a;
|
2024-05-10 04:01:14 +02:00
|
|
|
|
2024-07-02 12:18:32 +02:00
|
|
|
return _hov;
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-07-02 12:18:32 +02:00
|
|
|
static step = function() {
|
2024-01-20 05:06:56 +01:00
|
|
|
var _typ = getInputData(2);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 3].setVisible(_typ != 1);
|
|
|
|
inputs[ 4].setVisible(_typ == 1);
|
|
|
|
inputs[14].setVisible(_typ);
|
2024-01-20 05:06:56 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[1].mappableStep();
|
|
|
|
inputs[3].mappableStep();
|
|
|
|
inputs[4].mappableStep();
|
|
|
|
inputs[5].mappableStep();
|
|
|
|
inputs[9].mappableStep();
|
2024-07-02 12:18:32 +02:00
|
|
|
}
|
2023-12-23 09:39:55 +01:00
|
|
|
|
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 _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);
|
2024-08-08 06:57:51 +02:00
|
|
|
shader_set_gradient(_data[1], _data[15], _data[16], inputs[1]);
|
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
|
|
|
|
2024-08-08 06:57:51 +02: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
|
|
|
}
|
|
|
|
}
|