Pixel-Composer/scripts/node_gradient_extract/node_gradient_extract.gml

58 lines
1.5 KiB
Plaintext
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 {
2023-12-10 02:48:10 +01:00
name = "Gradient Data";
batch_output = false;
2024-03-28 14:18:02 +01:00
setDimension(96);
2023-03-02 07:59:14 +01:00
2024-08-18 09:13:41 +02:00
newInput(0, nodeValue_Gradient("Gradient", self, new gradientObject(cola(c_white))))
2023-03-02 07:59:14 +01:00
.setVisible(true, true);
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Colors", self, VALUE_TYPE.color, [] ))
2023-03-02 07:59:14 +01:00
.setDisplay(VALUE_DISPLAY.palette);
2024-09-04 03:57:11 +02:00
newOutput(1, nodeValue_Output("Positions", self, VALUE_TYPE.float, [] ));
2024-08-08 06:57:51 +02:00
outputs[1].array_depth = 1;
2023-03-02 07:59:14 +01:00
2024-09-04 03:57:11 +02:00
newOutput(2, nodeValue_Output("Type", self, VALUE_TYPE.integer, 0 ));
2023-03-02 07:59:14 +01:00
2024-08-06 14:04:41 +02:00
static processData = function(_outSurf, _data, _output_index, _array_index) {
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;
2024-08-06 14:04:41 +02:00
}
2023-03-02 07:59:14 +01:00
2024-08-06 14:04:41 +02:00
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
2023-03-02 07:59:14 +01:00
var bbox = drawGetBbox(xx, yy, _s);
if(bbox.h < 1) return;
2024-08-06 14:04:41 +02:00
var grad = getInputData(0);
2023-12-10 02:48:10 +01:00
if(!is_array(grad)) grad = [ grad ];
2024-08-06 14:04:41 +02:00
2023-12-10 02:48:10 +01:00
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;
2023-03-02 07:59:14 +01:00
}
2023-12-10 02:48:10 +01:00
if(_h != min_h) will_setHeight = true;
min_h = _h;
2024-08-06 14:04:41 +02:00
}
2023-03-02 07:59:14 +01:00
}