2023-02-28 09:43:01 +01:00
|
|
|
function Node_Gradient_Out(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2023-12-10 02:48:10 +01:00
|
|
|
name = "Gradient";
|
|
|
|
w = 96;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-01-08 08:10:50 +01:00
|
|
|
inputs[| 0] = nodeValue("Gradient", self, JUNCTION_CONNECT.input, VALUE_TYPE.gradient, new gradientObject([ cola(c_black), cola(c_white) ]) );
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 1] = nodeValue("Sample", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0, "Position to sample a color from the gradient.")
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider)
|
2023-01-25 06:49:00 +01:00
|
|
|
.rejectArray();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-05-28 20:00:51 +02:00
|
|
|
outputs[| 0] = nodeValue("Gradient", self, JUNCTION_CONNECT.output, VALUE_TYPE.gradient, new gradientObject(c_white) );
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
outputs[| 1] = nodeValue("Color", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, c_white);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
_pal = -1;
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2023-12-10 02:48:10 +01:00
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
2023-02-14 05:32:32 +01:00
|
|
|
var pal = _data[0];
|
|
|
|
var pos = _data[1];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-08-24 11:59:05 +02:00
|
|
|
if(!is_instanceof(pal, gradientObject)) return 0;
|
2023-03-13 10:45:56 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
if(_output_index == 0) return pal;
|
2023-03-02 07:59:14 +01:00
|
|
|
if(_output_index == 1) return pal.eval(pos);
|
2023-02-14 05:32:32 +01:00
|
|
|
return 0;
|
2023-12-10 02:48:10 +01:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-12-10 02:48:10 +01:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
2023-01-04 02:30:04 +01:00
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
if(bbox.h < 1) return;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-12-10 02:48:10 +01:00
|
|
|
var grad = outputs[| 0].getValue();
|
|
|
|
if(!is_array(grad)) grad = [ grad ];
|
|
|
|
var _h = array_length(grad) * 32;
|
|
|
|
|
|
|
|
var _y = bbox.y0;
|
|
|
|
var gh = bbox.h / array_length(grad);
|
|
|
|
|
|
|
|
for( var i = 0, n = array_length(grad); i < n; i++ ) {
|
|
|
|
grad[i].draw(bbox.x0, _y, bbox.w, gh);
|
|
|
|
_y += gh;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_h != min_h) will_setHeight = true;
|
|
|
|
min_h = _h;
|
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|