Pixel-Composer/scripts/node_gradient_output/node_gradient_output.gml

34 lines
1.1 KiB
Text
Raw Normal View History

2022-12-13 09:20:36 +01:00
function Node_Gradient_Out(_x, _y, _group = -1) : Node(_x, _y, _group) constructor {
2022-01-13 05:24:03 +01:00
name = "Gradient";
previewable = false;
w = 96;
inputs[| 0] = nodeValue(0, "Gradient", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white)
2022-01-19 03:05:13 +01:00
.setDisplay(VALUE_DISPLAY.gradient);
2022-01-13 05:24:03 +01:00
2023-01-25 06:49:00 +01:00
inputs[| 1] = nodeValue(1, "Sample", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0, "Position to sample a color from the gradient.")
.setDisplay(VALUE_DISPLAY.slider, [0, 1, 0.01])
.rejectArray();
2022-01-13 05:24:03 +01:00
2023-01-25 06:49:00 +01:00
outputs[| 0] = nodeValue(0, "Gradient", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, [])
.setDisplay(VALUE_DISPLAY.gradient);
2022-01-13 05:24:03 +01:00
outputs[| 1] = nodeValue(1, "Color", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, c_white);
_pal = -1;
2022-01-18 05:31:19 +01:00
static update = function() {
2022-01-13 05:24:03 +01:00
var pal = inputs[| 0].getValue();
var pos = inputs[| 1].getValue();
2023-01-25 06:49:00 +01:00
outputs[| 0].setValue(pal);
2022-01-13 05:24:03 +01:00
outputs[| 1].setValue(gradient_eval(pal, pos));
}
static onDrawNode = function(xx, yy, _mx, _my, _s) {
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-01-04 02:30:04 +01:00
draw_gradient(bbox.x0, bbox.y0, bbox.w, bbox.h, inputs[| 0].getValue(), inputs[| 0].extra_data[| 0]);
2022-01-13 05:24:03 +01:00
}
}