Pixel-Composer/scripts/node_path_array/node_path_array.gml

137 lines
3.5 KiB
Plaintext
Raw Normal View History

2023-03-07 14:29:47 +01:00
function Node_Path_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Path Array";
previewable = false;
w = 96;
2023-08-05 14:00:33 +02:00
setIsDynamicInput(1);
2023-03-07 14:29:47 +01:00
outputs[| 0] = nodeValue("Path array", self, JUNCTION_CONNECT.output, VALUE_TYPE.pathnode, self);
static createNewInput = function() {
var index = ds_list_size(inputs);
inputs[| index] = nodeValue("Path", self, JUNCTION_CONNECT.input, VALUE_TYPE.pathnode, noone )
.setVisible(true, true);
return inputs[| index];
}
if(!LOADING && !APPENDING) createNewInput();
static refreshDynamicInput = function() {
var _l = ds_list_create();
2023-03-11 01:40:17 +01:00
for( var i = 0; i < input_fix_len; i++ )
2023-03-07 14:29:47 +01:00
_l[| i] = inputs[| i];
2023-03-11 01:40:17 +01:00
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
2023-03-07 14:29:47 +01:00
if(inputs[| i].value_from)
ds_list_add(_l, inputs[| i]);
else
delete inputs[| i];
}
for( var i = 0; i < ds_list_size(_l); i++ )
_l[| i].index = i;
ds_list_destroy(inputs);
inputs = _l;
createNewInput();
}
static onValueFromUpdate = function(index) {
if(LOADING || APPENDING) return;
refreshDynamicInput();
}
static getLineCount = function() {
var l = 0;
2023-03-11 01:40:17 +01:00
for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i += data_length ) {
2023-03-07 14:29:47 +01:00
var _path = inputs[| i].getValue();
l += struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
}
return l;
}
2023-08-02 19:11:57 +02:00
static getSegmentCount = function(ind = 0) {
2023-03-19 09:17:39 +01:00
for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i += data_length ) {
var _path = inputs[| i].getValue();
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
2023-08-02 19:11:57 +02:00
if(ind < lc) return _path.getSegmentCount(ind);
2023-03-19 09:17:39 +01:00
ind -= lc;
}
return 0;
}
2023-08-02 19:11:57 +02:00
static getLength = function(ind = 0) {
2023-03-19 09:17:39 +01:00
for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i += data_length ) {
var _path = inputs[| i].getValue();
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
2023-08-02 19:11:57 +02:00
if(ind < lc) return _path.getLength(ind);
2023-03-19 09:17:39 +01:00
ind -= lc;
}
return 0;
}
static getAccuLength = function(ind = 0) {
for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i += data_length ) {
var _path = inputs[| i].getValue();
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
2023-03-29 15:02:03 +02:00
if(ind < lc) return _path.getAccuLength(ind);
2023-03-19 09:17:39 +01:00
ind -= lc;
}
return 0;
}
static get__vec2Ratio = function(_rat, ind = 0) {
2023-03-19 09:17:39 +01:00
for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i += data_length ) {
var _path = inputs[| i].getValue();
2023-08-02 19:11:57 +02:00
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
2023-03-19 09:17:39 +01:00
if(ind < lc) return _path.get__vec2Ratio(_rat, ind).clone();
2023-03-19 09:17:39 +01:00
ind -= lc;
}
return new __vec2();
2023-03-07 14:29:47 +01:00
}
static get__vec2Distance = function(_dist, ind = 0) {
2023-03-11 01:40:17 +01:00
for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i += data_length ) {
2023-03-07 14:29:47 +01:00
var _path = inputs[| i].getValue();
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
if(ind < lc) return _path.get__vec2Distance(_dist, ind).clone();
2023-03-19 09:17:39 +01:00
ind -= lc;
}
return new __vec2();
2023-03-19 09:17:39 +01:00
}
2023-08-02 19:11:57 +02:00
static getBoundary = function(ind = 0) {
2023-03-19 09:17:39 +01:00
for( var i = input_fix_len; i < ds_list_size(inputs) - 1; i += data_length ) {
var _path = inputs[| i].getValue();
2023-08-02 19:11:57 +02:00
var lc = struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
2023-03-19 09:17:39 +01:00
2023-08-02 19:11:57 +02:00
if(ind < lc) return _path.getBoundary(ind);
2023-03-07 14:29:47 +01:00
ind -= lc;
}
2023-08-02 19:11:57 +02:00
return 0;
2023-03-07 14:29:47 +01:00
}
2023-07-06 19:49:16 +02:00
static update = function(frame = PROJECT.animator.current_frame) {
2023-03-07 14:29:47 +01:00
outputs[| 0].setValue(self);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
}
}