2023-02-28 15:43:01 +07:00
|
|
|
function Node_Gradient_Out(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2023-12-10 08:48:10 +07:00
|
|
|
name = "Gradient";
|
2024-06-28 13:40:21 +07:00
|
|
|
batch_output = false;
|
2024-03-28 20:18:02 +07:00
|
|
|
setDimension(96);
|
2022-01-13 11:24:03 +07:00
|
|
|
|
2024-08-18 11:16:20 +07:00
|
|
|
newInput(0, nodeValue_Gradient("Gradient", self, new gradientObject([ cola(c_black), cola(c_white) ])));
|
2022-01-13 11:24:03 +07:00
|
|
|
|
2024-08-18 14:13:41 +07:00
|
|
|
newInput(1, nodeValue_Float("Sample", self, 0, "Position to sample a color from the gradient."))
|
2023-10-02 13:57:44 +07:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider)
|
2023-01-25 12:49:00 +07:00
|
|
|
.rejectArray();
|
2022-01-13 11:24:03 +07:00
|
|
|
|
2024-09-04 08:57:11 +07:00
|
|
|
newOutput(0, nodeValue_Output("Gradient", self, VALUE_TYPE.gradient, new gradientObject(cola(c_white)) ));
|
2022-01-13 11:24:03 +07:00
|
|
|
|
2024-09-04 08:57:11 +07:00
|
|
|
newOutput(1, nodeValue_Output("Color", self, VALUE_TYPE.color, c_white));
|
2022-01-13 11:24:03 +07:00
|
|
|
|
|
|
|
_pal = -1;
|
2023-02-14 11:32:32 +07:00
|
|
|
|
2024-11-23 13:26:39 +07:00
|
|
|
static processData_prebatch = function() {
|
|
|
|
setDimension(96, process_length[0] * 32);
|
|
|
|
}
|
|
|
|
|
2024-07-27 12:10:34 +07:00
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
2023-02-14 11:32:32 +07:00
|
|
|
var pal = _data[0];
|
|
|
|
var pos = _data[1];
|
2022-01-13 11:24:03 +07:00
|
|
|
|
2023-08-24 11:59:05 +02:00
|
|
|
if(!is_instanceof(pal, gradientObject)) return 0;
|
2023-03-13 16:45:56 +07:00
|
|
|
|
2023-02-14 11:32:32 +07:00
|
|
|
if(_output_index == 0) return pal;
|
2023-03-02 13:59:14 +07:00
|
|
|
if(_output_index == 1) return pal.eval(pos);
|
2023-02-14 11:32:32 +07:00
|
|
|
return 0;
|
2024-07-27 12:10:34 +07:00
|
|
|
}
|
2022-01-13 11:24:03 +07:00
|
|
|
|
2024-07-27 12:10:34 +07:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
2023-01-04 08:30:04 +07:00
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
if(bbox.h < 1) return;
|
2022-01-13 11:24:03 +07:00
|
|
|
|
2024-08-08 11:57:51 +07:00
|
|
|
var grad = outputs[0].getValue();
|
2023-12-10 08:48:10 +07:00
|
|
|
if(!is_array(grad)) grad = [ grad ];
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2024-07-27 12:10:34 +07:00
|
|
|
}
|
2022-01-13 11:24:03 +07:00
|
|
|
}
|