Pixel-Composer/scripts/node_gradient_extract/node_gradient_extract.gml

50 lines
1.4 KiB
Text
Raw Normal View History

2023-03-02 07:59:14 +01:00
function Node_Gradient_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Gradient Data";
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) )
2023-03-02 07:59:14 +01:00
.setVisible(true, true);
outputs[| 0] = nodeValue("Colors", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, [] )
.setDisplay(VALUE_DISPLAY.palette);
outputs[| 1] = nodeValue("Positions", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [] );
outputs[| 1].array_depth = 1;
outputs[| 2] = nodeValue("Type", self, JUNCTION_CONNECT.output, VALUE_TYPE.integer, 0 );
2023-12-04 12:09:31 +01:00
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
2023-03-02 07:59:14 +01:00
var gra = _data[0];
switch(_output_index) {
case 0 :
var pal = [];
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(gra.keys); i < n; i++ )
2023-03-02 07:59:14 +01:00
pal[i] = gra.keys[i].value;
return pal;
case 1 :
var pos = [];
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(gra.keys); i < n; i++ )
2023-03-02 07:59:14 +01:00
pos[i] = gra.keys[i].time;
return pos;
case 2 :
return gra.type;
}
return 0;
2023-12-04 12:09:31 +01:00
} #endregion
2023-03-02 07:59:14 +01:00
2023-12-04 12:09:31 +01:00
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
2023-03-02 07:59:14 +01:00
var bbox = drawGetBbox(xx, yy, _s);
if(bbox.h < 1) return;
var grad = getInputData(0);
2023-03-02 07:59:14 +01:00
if(is_array(grad)) {
if(array_length(grad) == 0) return;
grad = grad[0];
}
grad.draw(bbox.x0, bbox.y0, bbox.w, bbox.h);
2023-12-04 12:09:31 +01:00
} #endregion
2023-03-02 07:59:14 +01:00
}