Pixel-Composer/scripts/node_path_reverse/node_path_reverse.gml

62 lines
2.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 {
2024-01-22 14:23:35 +01:00
name = "Reverse Path";
w = 96;
2023-02-20 10:16:31 +01:00
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);
cached_pos = ds_map_create();
2024-01-22 14:23:35 +01:00
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
var _path = getInputData(0);
if(_path) _path.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
} #endregion
static getLineCount = function() { #region
var _path = getInputData(0);
2023-03-07 14:29:47 +01:00
return struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
2024-01-22 14:23:35 +01:00
} #endregion
2023-03-07 14:29:47 +01:00
2024-01-22 14:23:35 +01:00
static getSegmentCount = function(ind = 0) { #region
var _path = getInputData(0);
2023-08-02 19:11:57 +02:00
return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 0;
2024-01-22 14:23:35 +01:00
} #endregion
2023-02-28 09:43:01 +01:00
2024-01-22 14:23:35 +01:00
static getLength = function(ind = 0) { #region
var _path = getInputData(0);
2023-08-02 19:11:57 +02:00
return struct_has(_path, "getLength")? _path.getLength(ind) : 0;
2024-01-22 14:23:35 +01:00
} #endregion
2023-04-09 21:24:16 +02:00
2024-01-22 14:23:35 +01:00
static getAccuLength = function(ind = 0) { #region
var _path = getInputData(0);
2023-08-02 19:11:57 +02:00
return struct_has(_path, "getAccuLength")? array_reverse(_path.getAccuLength(ind)) : [];
2024-01-22 14:23:35 +01:00
} #endregion
2023-03-19 09:17:39 +01:00
2024-01-22 14:23:35 +01:00
static getBoundary = function(ind = 0) { #region
var _path = getInputData(0);
2023-08-02 19:11:57 +02:00
return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox(0, 0, 1, 1);
2024-01-22 14:23:35 +01:00
} #endregion
2023-02-20 10:16:31 +01:00
2024-01-22 14:23:35 +01:00
static getPointRatio = function(_rat, ind = 0, out = undefined) { #region
2023-10-29 06:29:10 +01:00
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
var _path = getInputData(0);
2023-03-07 14:29:47 +01:00
2023-02-20 10:16:31 +01:00
if(!is_struct(_path) || !struct_has(_path, "getPointRatio"))
2023-10-29 06:29:10 +01:00
return out;
return _path.getPointRatio(1 - _rat, ind, out);
2024-01-22 14:23:35 +01:00
} #endregion
2023-03-19 09:17:39 +01:00
2023-10-29 06:29:10 +01:00
static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); }
2023-02-20 10:16:31 +01:00
2024-01-22 14:23:35 +01:00
static update = function() { #region
ds_map_clear(cached_pos);
2023-02-20 10:16:31 +01:00
outputs[| 0].setValue(self);
2024-01-22 14:23:35 +01:00
} #endregion
2023-02-20 10:16:31 +01:00
2024-01-22 14:23:35 +01:00
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
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);
2024-01-22 14:23:35 +01:00
} #endregion
2023-02-20 10:16:31 +01:00
}