Pixel-Composer/scripts/node_path_reverse/node_path_reverse.gml

45 lines
1.2 KiB
Plaintext
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Path_Reverse(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
2023-02-20 10:16:31 +01:00
name = "Reverse Path";
previewable = false;
w = 96;
inputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.input, VALUE_TYPE.pathnode, noone)
.setVisible(true, true);
outputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.output, VALUE_TYPE.pathnode, self);
2023-03-07 14:29:47 +01:00
static getLineCount = function() {
var _path = inputs[| 0].getValue();
return struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
}
2023-02-28 09:43:01 +01:00
static getSegmentCount = function() {
var _path = inputs[| 0].getValue();
return struct_has(_path, "getSegmentCount")? _path.getSegmentCount() : 0;
}
2023-03-07 14:29:47 +01:00
static getPointRatio = function(_rat, ind = 0) {
2023-02-20 10:16:31 +01:00
var _path = inputs[| 0].getValue();
2023-03-07 14:29:47 +01:00
if(is_array(_path)) {
_path = array_safe_get(_path, ind);
ind = 0;
}
2023-02-20 10:16:31 +01:00
if(!is_struct(_path) || !struct_has(_path, "getPointRatio"))
return [ 0, 0 ];
2023-03-07 14:29:47 +01:00
var _p = _path.getPointRatio(1 - _rat, ind);
2023-02-20 10:16:31 +01:00
return _p;
}
function update() {
outputs[| 0].setValue(self);
}
2023-03-05 07:16:44 +01:00
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
2023-02-20 10:16:31 +01:00
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
}