Pixel-Composer/scripts/node_gradient_output/node_gradient_output.gml

37 lines
1.2 KiB
Text
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Gradient_Out(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
2022-01-13 05:24:03 +01:00
name = "Gradient";
previewable = false;
w = 96;
2023-05-28 20:00:51 +02:00
inputs[| 0] = nodeValue("Gradient", self, JUNCTION_CONNECT.input, VALUE_TYPE.gradient, new gradientObject(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.")
.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-08-17 16:56:54 +02:00
static processData = function(_outSurf, _data, _output_index, _array_index) {
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;
2022-01-13 05:24:03 +01:00
}
2023-03-05 07:16:44 +01:00
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
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-02-14 05:32:32 +01:00
var grad = getSingleValue(0);
2023-03-02 07:59:14 +01:00
grad.draw(bbox.x0, bbox.y0, bbox.w, bbox.h);
2022-01-13 05:24:03 +01:00
}
}