mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-02-03 08:45:17 +01:00
[Path] Add variable weight support.
This commit is contained in:
parent
e305ae3793
commit
3aba27f9bd
46 changed files with 839 additions and 561 deletions
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"tooltip":"Custom node",
|
"tooltip":"Custom node",
|
||||||
"spr":"__newsprite1112",
|
"spr":"s_node_icon",
|
||||||
"baseNode":"Node_Custom",
|
"baseNode":"Node_Custom",
|
||||||
"io":[
|
"io":[
|
||||||
],
|
],
|
||||||
|
|
|
@ -11,6 +11,6 @@
|
||||||
"intersection",
|
"intersection",
|
||||||
"difference",
|
"difference",
|
||||||
"xor",
|
"xor",
|
||||||
]
|
],
|
||||||
"pxc_version":118069,
|
"pxc_version":118069,
|
||||||
}
|
}
|
Binary file not shown.
|
@ -13,7 +13,7 @@ function Path() constructor {
|
||||||
|
|
||||||
static getTangentRatio = function(_rat) { return 0; }
|
static getTangentRatio = function(_rat) { return 0; }
|
||||||
|
|
||||||
static getPointDistance = function(_seg, _ind = 0, out = undefined) { return new __vec2(0, 0); }
|
static getPointDistance = function(_seg, _ind = 0, out = undefined) { return new __vec2P(0, 0); }
|
||||||
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
||||||
var pix = frac(_rat) * lengthTotal;
|
var pix = frac(_rat) * lengthTotal;
|
||||||
return getPointDistance(pix, _ind, out);
|
return getPointDistance(pix, _ind, out);
|
||||||
|
@ -64,7 +64,7 @@ function PathSegment() : Path() constructor {
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
static getPointDistance = function(_dist, _ind = 0, out = undefined) { #region
|
static getPointDistance = function(_dist, _ind = 0, out = undefined) { #region
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
for( var i = 0; i < array_length(lengths); i++ ) {
|
for( var i = 0; i < array_length(lengths); i++ ) {
|
||||||
if(_dist <= lengths[i]) {
|
if(_dist <= lengths[i]) {
|
||||||
|
|
|
@ -132,9 +132,7 @@
|
||||||
var v0 = array_safe_get_fast(arr, floor(index));
|
var v0 = array_safe_get_fast(arr, floor(index));
|
||||||
var v1 = array_safe_get_fast(arr, floor(index) + 1);
|
var v1 = array_safe_get_fast(arr, floor(index) + 1);
|
||||||
|
|
||||||
return color?
|
return color? merge_color(v0, v1, frac(index)) : lerp(v0, v1, frac(index));
|
||||||
merge_color(v0, v1, frac(index)) :
|
|
||||||
lerp(v0, v1, frac(index));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_safe_length(arr) {
|
function array_safe_length(arr) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function __initCollection() {
|
function __initCollection() {
|
||||||
printDebug("COLLECTION", "init");
|
printDebug("COLLECTION: init");
|
||||||
|
|
||||||
globalvar COLLECTIONS;
|
globalvar COLLECTIONS;
|
||||||
COLLECTIONS = -1;
|
COLLECTIONS = -1;
|
||||||
|
@ -15,7 +15,7 @@ function __initCollection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshCollections() {
|
function refreshCollections() {
|
||||||
printDebug("COLLECTION", "refreshing collection base folder.");
|
printDebug("COLLECTION: refreshing collection base folder.");
|
||||||
|
|
||||||
COLLECTIONS = new DirectoryObject(DIRECTORY + "Collections");
|
COLLECTIONS = new DirectoryObject(DIRECTORY + "Collections");
|
||||||
COLLECTIONS.scan([".json", ".pxcc"]);
|
COLLECTIONS.scan([".json", ".pxcc"]);
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
function distance_to_line(_px, _py, _x0, _y0, _x1, _y1, log = false) {
|
function point_to_line(_px, _py, _x0, _y0, _x1, _y1) {
|
||||||
INLINE
|
var l2 = sqr(_x0 - _x1) + sqr(_y0 - _y1);
|
||||||
|
if (l2 == 0) return [ _x0, _y0 ];
|
||||||
|
|
||||||
|
var t = ((_px - _x0) * (_x1 - _x0) + (_py - _y0) * (_y1 - _y0)) / l2;
|
||||||
|
t = clamp(t, 0, 1);
|
||||||
|
return [ lerp(_x0, _x1, t), lerp(_y0, _y1, t) ];
|
||||||
|
}
|
||||||
|
|
||||||
|
function distance_to_line(_px, _py, _x0, _y0, _x1, _y1) {
|
||||||
var l2 = sqr(_x0 - _x1) + sqr(_y0 - _y1);
|
var l2 = sqr(_x0 - _x1) + sqr(_y0 - _y1);
|
||||||
if (l2 == 0) return point_distance(_px, _py, _x0, _y0);
|
if (l2 == 0) return point_distance(_px, _py, _x0, _y0);
|
||||||
|
|
||||||
|
@ -11,7 +19,6 @@ function distance_to_line(_px, _py, _x0, _y0, _x1, _y1, log = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function distance_to_line_infinite(px, py, x0, y0, x1, y1) {
|
function distance_to_line_infinite(px, py, x0, y0, x1, y1) {
|
||||||
INLINE
|
|
||||||
return abs((x1 - x0) * (y0 - py) - (x0 - px) * (y1 - y0)) / sqrt(sqr(x1 - x0) + sqr(y1 - y0));
|
return abs((x1 - x0) * (y0 - py) - (x0 - px) * (y1 - y0)) / sqrt(sqr(x1 - x0) + sqr(y1 - y0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
LATEST_VERSION = 1_18_00_0;
|
LATEST_VERSION = 1_18_00_0;
|
||||||
VERSION = 1_18_06_2;
|
VERSION = 1_18_06_2;
|
||||||
SAVE_VERSION = 1_18_05_0;
|
SAVE_VERSION = 1_18_05_0;
|
||||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.7.009";
|
VERSION_STRING = MAC? "1.18.003m" : "1.18.7.010";
|
||||||
BUILD_NUMBER = 118069;
|
BUILD_NUMBER = 118069;
|
||||||
PREF_VERSION = 1_17_1;
|
PREF_VERSION = 1_17_1;
|
||||||
|
|
||||||
|
|
|
@ -35,3 +35,5 @@ function lerp_color(from, to, ratio) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function lerp_invert(val, from, to) { return (val - from) / (to - from); }
|
function lerp_invert(val, from, to) { return (val - from) / (to - from); }
|
||||||
|
|
||||||
|
function lerp_smooth(_x) { return _x * _x * (3.0 - 2.0 * _x) }
|
|
@ -51,7 +51,7 @@ function Node_3D_Mesh_Wall_Builder(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y
|
||||||
if(_paths == noone) return noone;
|
if(_paths == noone) return noone;
|
||||||
|
|
||||||
var points = array_create(_segment + 1);
|
var points = array_create(_segment + 1);
|
||||||
var p = new __vec2();
|
var p = new __vec2P();
|
||||||
|
|
||||||
for( var i = 0; i <= _segment; i++ ) {
|
for( var i = 0; i <= _segment; i++ ) {
|
||||||
p = _paths.getPointRatio(i / _segment, 0, p);
|
p = _paths.getPointRatio(i / _segment, 0, p);
|
||||||
|
|
|
@ -47,7 +47,7 @@ function Node_VFX_Trail(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
||||||
static getAccuLength = function(index) { return array_safe_get_fast(lengthAcc, index, []); }
|
static getAccuLength = function(index) { return array_safe_get_fast(lengthAcc, index, []); }
|
||||||
|
|
||||||
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _p0, _p1;
|
var _p0, _p1;
|
||||||
var _x, _y;
|
var _x, _y;
|
||||||
|
|
|
@ -55,7 +55,7 @@ function Node_Armature_Path(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
||||||
static getPointDistance = function(_dist, _ind = 0, out = undefined) { return getPointRatio(_dist / current_length, _ind, out); }
|
static getPointDistance = function(_dist, _ind = 0, out = undefined) { return getPointRatio(_dist / current_length, _ind, out); }
|
||||||
|
|
||||||
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _p0 = lines[_ind][0];
|
var _p0 = lines[_ind][0];
|
||||||
var _p1 = lines[_ind][1];
|
var _p1 = lines[_ind][1];
|
||||||
|
|
|
@ -73,7 +73,7 @@ function Node_Blur_Path(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
var _dim = surface_get_dimension(_surf)
|
var _dim = surface_get_dimension(_surf)
|
||||||
var _points_x = array_create(_pntc);
|
var _points_x = array_create(_pntc);
|
||||||
var _points_y = array_create(_pntc);
|
var _points_y = array_create(_pntc);
|
||||||
var _p = new __vec2();
|
var _p = new __vec2P();
|
||||||
|
|
||||||
var _rst = _rang[0];
|
var _rst = _rang[0];
|
||||||
var _red = _rang[1];
|
var _red = _rang[1];
|
||||||
|
|
|
@ -2376,10 +2376,16 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
||||||
return _tool.selecting == subtool;
|
return _tool.selecting == subtool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getUsingToolName = function() {
|
||||||
|
var _tool = PANEL_PREVIEW.tool_current;
|
||||||
|
return _tool == noone? "" : _tool.getName(_tool.selecting);
|
||||||
|
}
|
||||||
|
|
||||||
static isNotUsingTool = function() { return PANEL_PREVIEW.tool_current == noone; }
|
static isNotUsingTool = function() { return PANEL_PREVIEW.tool_current == noone; }
|
||||||
|
|
||||||
static getTool = function() { return self; }
|
static getTool = function() { return self; }
|
||||||
|
|
||||||
|
|
||||||
static getToolSettings = function() { return tool_settings; }
|
static getToolSettings = function() { return tool_settings; }
|
||||||
|
|
||||||
static setTool = function(tool) {
|
static setTool = function(tool) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ function Node_Fn_SmoothStep(_x, _y, _group = noone) : Node_Fn(_x, _y, _group) co
|
||||||
return i / graph_res;
|
return i / graph_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
|
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||||
value = _data[inl + 0];
|
value = _data[inl + 0];
|
||||||
type = _data[inl + 1];
|
type = _data[inl + 1];
|
||||||
|
|
||||||
|
@ -40,6 +40,6 @@ function Node_Fn_SmoothStep(_x, _y, _group = noone) : Node_Fn(_x, _y, _group) co
|
||||||
|
|
||||||
text_display = val;
|
text_display = val;
|
||||||
return val;
|
return val;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -259,7 +259,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
random_set_seed(_sed);
|
random_set_seed(_sed);
|
||||||
var _sedIndex = 0;
|
var _sedIndex = 0;
|
||||||
|
|
||||||
var p = new __vec2();
|
var p = new __vec2P();
|
||||||
var _pathData = [];
|
var _pathData = [];
|
||||||
var minx = 999999, miny = 999999, maxx = -999999, maxy = -999999;
|
var minx = 999999, miny = 999999, maxx = -999999, maxy = -999999;
|
||||||
|
|
||||||
|
@ -402,8 +402,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
// print($"_pp = {_pp}, total = {_total}");
|
// print($"_pp = {_pp}, total = {_total}");
|
||||||
|
|
||||||
p = _pat.getPointDistance(_pp, i, p);
|
p = _pat.getPointDistance(_pp, i, p);
|
||||||
if(struct_has(_pat, "getWeightDistance"))
|
wght = p[$ "weight"] ?? 1;
|
||||||
wght = _pat.getWeightDistance(_pp, i);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_prog_next = min(_prog_curr + _stepLen, 1); //Move forward _stepLen or _total (if less) stop at 1
|
_prog_next = min(_prog_curr + _stepLen, 1); //Move forward _stepLen or _total (if less) stop at 1
|
||||||
|
@ -412,8 +411,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
var _pp = _clamp? clamp(_pathPng, 0, 1) : _pathPng
|
var _pp = _clamp? clamp(_pathPng, 0, 1) : _pathPng
|
||||||
|
|
||||||
p = _pat.getPointRatio(_pp, i, p);
|
p = _pat.getPointRatio(_pp, i, p);
|
||||||
if(struct_has(_pat, "getWeightRatio"))
|
wght = p[$ "weight"] ?? 1;
|
||||||
wght = _pat.getWeightRatio(_pp, i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_nx = p.x;
|
_nx = p.x;
|
||||||
|
@ -605,7 +603,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
if(!ds_map_exists(widthMap, widProg))
|
if(!ds_map_exists(widthMap, widProg))
|
||||||
widthMap[? widProg] = eval_curve_x(_widc, widProg, 0.1);
|
widthMap[? widProg] = eval_curve_x(_widc, widProg, 0.1);
|
||||||
_nw *= widthMap[? widProg];
|
_nw *= widthMap[? widProg];
|
||||||
_nw *= p0.weight;
|
_nw *= p0.weight / 2;
|
||||||
|
|
||||||
_nc = colorMultiply(_col_base, _color.eval(_colP? prog : prgc));
|
_nc = colorMultiply(_col_base, _color.eval(_colP? prog : prgc));
|
||||||
|
|
||||||
|
|
|
@ -265,7 +265,7 @@ function Node_Liquefy(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
|
||||||
if(_type == LIQUEFY_TYPE.push) {
|
if(_type == LIQUEFY_TYPE.push) {
|
||||||
var _usePath = _path != noone;
|
var _usePath = _path != noone;
|
||||||
var _pthList = array_create(_pthR * 2);
|
var _pthList = array_create(_pthR * 2);
|
||||||
var _p = new __vec2();
|
var _p = new __vec2P();
|
||||||
|
|
||||||
if(_usePath) {
|
if(_usePath) {
|
||||||
for( var i = 0; i < _pthR; i++ ) {
|
for( var i = 0; i < _pthR; i++ ) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ function Node_Mesh_To_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
||||||
l -= lengths[i];
|
l -= lengths[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return new __vec2();
|
return new __vec2P();
|
||||||
}
|
}
|
||||||
|
|
||||||
static update = function() {
|
static update = function() {
|
||||||
|
|
|
@ -417,8 +417,8 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isUsingTool("Edit control point")) {
|
if(isUsingTool("Edit control point")) {
|
||||||
if(key_mod_press(SHIFT)) draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 16, _my + 16);
|
if(key_mod_press(SHIFT)) draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 4, _my + 4);
|
||||||
else draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 16, _my + 16);
|
else draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
if(mouse_press(mb_left, active)) {
|
||||||
if(_hover == -1) {
|
if(_hover == -1) {
|
||||||
|
@ -438,7 +438,7 @@ function Node_Mesh_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
control(input_display_list);
|
control(input_display_list);
|
||||||
}
|
}
|
||||||
} else if(isUsingTool("Pin mesh")) {
|
} else if(isUsingTool("Pin mesh")) {
|
||||||
draw_sprite_ui_uniform(key_mod_press(SHIFT)? THEME.cursor_path_remove : THEME.cursor_path_add, 0, _mx + 16, _my + 16);
|
draw_sprite_ui_uniform(key_mod_press(SHIFT)? THEME.cursor_path_remove : THEME.cursor_path_add, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
draw_set_color(COLORS._main_accent);
|
draw_set_color(COLORS._main_accent);
|
||||||
var rad = 16;
|
var rad = 16;
|
||||||
|
|
|
@ -10,6 +10,12 @@ enum _ANCHOR {
|
||||||
amount
|
amount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function __vec2P(_x = 0, _y = _x, _w = 1) : __vec2(_x, _y) constructor {
|
||||||
|
weight = _w;
|
||||||
|
|
||||||
|
static clone = function() /*=>*/ {return new __vec2P(x, y, weight)};
|
||||||
|
}
|
||||||
|
|
||||||
function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
name = "Path";
|
name = "Path";
|
||||||
|
|
||||||
|
@ -48,8 +54,8 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
setDynamicInput(1, false);
|
setDynamicInput(1, false);
|
||||||
|
|
||||||
tool_pathDrawer = new NodeTool( "Draw path", THEME.path_tools_draw )
|
tool_pathDrawer = new NodeTool( "Draw path", THEME.path_tools_draw )
|
||||||
.addSetting("Smoothness", VALUE_TYPE.float, function(val) { tool_pathDrawer.attribute.thres = val; }, "thres", 4)
|
.addSetting("Smoothness", VALUE_TYPE.float, function(val) /*=>*/ { tool_pathDrawer.attribute.thres = val; }, "thres", 4)
|
||||||
.addSetting("Replace", VALUE_TYPE.boolean, function() { tool_pathDrawer.attribute.create = !tool_pathDrawer.attribute.create; }, "create", true);
|
.addSetting("Replace", VALUE_TYPE.boolean, function( ) /*=>*/ { tool_pathDrawer.attribute.create = !tool_pathDrawer.attribute.create; }, "create", true);
|
||||||
|
|
||||||
tools = [
|
tools = [
|
||||||
new NodeTool( "Transform", THEME.path_tools_transform ),
|
new NodeTool( "Transform", THEME.path_tools_transform ),
|
||||||
|
@ -58,6 +64,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
tool_pathDrawer,
|
tool_pathDrawer,
|
||||||
new NodeTool( "Rectangle path", THEME.path_tools_rectangle ),
|
new NodeTool( "Rectangle path", THEME.path_tools_rectangle ),
|
||||||
new NodeTool( "Circle path", THEME.path_tools_circle ),
|
new NodeTool( "Circle path", THEME.path_tools_circle ),
|
||||||
|
new NodeTool( "Weight edit", THEME.path_tools_weight_edit ),
|
||||||
];
|
];
|
||||||
|
|
||||||
#region ---- path ----
|
#region ---- path ----
|
||||||
|
@ -66,14 +73,19 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
segments = [];
|
segments = [];
|
||||||
lengths = [];
|
lengths = [];
|
||||||
lengthAccs = [];
|
lengthAccs = [];
|
||||||
|
lengthRatio = [];
|
||||||
lengthTotal = 0;
|
lengthTotal = 0;
|
||||||
|
weightRatio = array_create(100 + 1);
|
||||||
boundary = new BoundingBox();
|
boundary = new BoundingBox();
|
||||||
|
|
||||||
cached_pos = ds_map_create();
|
cached_pos = ds_map_create();
|
||||||
|
|
||||||
|
attributes.weight = [ [ 0, 1 ], [ 100, 1 ] ];
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ---- editor ----
|
#region ---- editor ----
|
||||||
line_hover = -1;
|
line_hover = -1;
|
||||||
|
weight_hover = -1;
|
||||||
|
|
||||||
drag_point = -1;
|
drag_point = -1;
|
||||||
drag_points = [];
|
drag_points = [];
|
||||||
|
@ -89,6 +101,12 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
transform_cx = 0; transform_cy = 0;
|
transform_cx = 0; transform_cy = 0;
|
||||||
transform_sx = 0; transform_sy = 0;
|
transform_sx = 0; transform_sy = 0;
|
||||||
transform_mx = 0; transform_my = 0;
|
transform_mx = 0; transform_my = 0;
|
||||||
|
|
||||||
|
weight_drag = noone;
|
||||||
|
weight_drag_sx = 0;
|
||||||
|
weight_drag_sy = 0;
|
||||||
|
weight_drag_mx = 0;
|
||||||
|
weight_drag_my = 0;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
static resetDisplayList = function() {
|
static resetDisplayList = function() {
|
||||||
|
@ -102,7 +120,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static newAnchor = function(_x = 0, _y = 0, _dxx = 0, _dxy = 0, _dyx = 0, _dyy = 0) { return [ _x, _y, _dxx, _dxy, _dyx, _dyy, false ]; }
|
static newAnchor = function(_x = 0, _y = 0, _dxx = 0, _dxy = 0, _dyx = 0, _dyy = 0) { return [ _x, _y, _dxx, _dxy, _dyx, _dyy, 0 ]; }
|
||||||
|
|
||||||
static createNewInput = function(_x = 0, _y = 0, _dxx = 0, _dxy = 0, _dyx = 0, _dyy = 0, rec = true) {
|
static createNewInput = function(_x = 0, _y = 0, _dxx = 0, _dxy = 0, _dyx = 0, _dyy = 0, rec = true) {
|
||||||
var index = array_length(inputs);
|
var index = array_length(inputs);
|
||||||
|
@ -130,14 +148,17 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
var ansize = array_length(inputs) - input_fix_len;
|
var ansize = array_length(inputs) - input_fix_len;
|
||||||
var edited = false;
|
var edited = false;
|
||||||
|
var _tooln = getUsingToolName();
|
||||||
|
|
||||||
var pos = outputs[0].getValue();
|
var pos = outputs[0].getValue();
|
||||||
var p/*:_ANCHOR*/;
|
var p/*:_ANCHOR*/;
|
||||||
|
|
||||||
|
if(_tooln == "") {
|
||||||
draw_set_color(COLORS._main_accent);
|
draw_set_color(COLORS._main_accent);
|
||||||
draw_circle(_x + pos[0] * _s, _y + pos[1] * _s, 4, false);
|
draw_circle(_x + pos[0] * _s, _y + pos[1] * _s, 4, false);
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////// EDIT ///////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////// EDITING ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if(transform_type > 0) {
|
if(transform_type > 0) {
|
||||||
var _transform_minx = transform_minx;
|
var _transform_minx = transform_minx;
|
||||||
|
@ -296,17 +317,19 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
var dx = value_snap(drag_point_sx + (_mx - drag_point_mx) / _s, _snx);
|
var dx = value_snap(drag_point_sx + (_mx - drag_point_mx) / _s, _snx);
|
||||||
var dy = value_snap(drag_point_sy + (_my - drag_point_my) / _s, _sny);
|
var dy = value_snap(drag_point_sy + (_my - drag_point_my) / _s, _sny);
|
||||||
|
|
||||||
if(drag_type < 2) { // move points
|
switch(drag_type) {
|
||||||
|
case 0 :
|
||||||
|
case 1 :
|
||||||
|
case -1 :
|
||||||
var inp = inputs[input_fix_len + drag_point];
|
var inp = inputs[input_fix_len + drag_point];
|
||||||
|
var rnd = key_mod_press(CTRL);
|
||||||
var anc/*:_ANCHOR*/ = array_clone(inp.getValue());
|
var anc/*:_ANCHOR*/ = array_clone(inp.getValue());
|
||||||
|
|
||||||
if(drag_type != 0 && key_mod_press(SHIFT))
|
|
||||||
anc[@_ANCHOR.ind] = !anc[_ANCHOR.ind];
|
|
||||||
|
|
||||||
if(drag_type == 0) { //drag anchor point
|
if(drag_type == 0) { //drag anchor point
|
||||||
anc[@_ANCHOR.x] = dx;
|
anc[@_ANCHOR.x] = dx;
|
||||||
anc[@_ANCHOR.y] = dy;
|
anc[@_ANCHOR.y] = dy;
|
||||||
if(key_mod_press(CTRL)) {
|
|
||||||
|
if(rnd) {
|
||||||
anc[@_ANCHOR.x] = round(anc[_ANCHOR.x]);
|
anc[@_ANCHOR.x] = round(anc[_ANCHOR.x]);
|
||||||
anc[@_ANCHOR.y] = round(anc[_ANCHOR.y]);
|
anc[@_ANCHOR.y] = round(anc[_ANCHOR.y]);
|
||||||
}
|
}
|
||||||
|
@ -315,16 +338,23 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
anc[@_ANCHOR.c1x] = dx - anc[_ANCHOR.x];
|
anc[@_ANCHOR.c1x] = dx - anc[_ANCHOR.x];
|
||||||
anc[@_ANCHOR.c1y] = dy - anc[_ANCHOR.y];
|
anc[@_ANCHOR.c1y] = dy - anc[_ANCHOR.y];
|
||||||
|
|
||||||
if(!anc[_ANCHOR.ind]) {
|
if(anc[_ANCHOR.ind] == 0) {
|
||||||
anc[@_ANCHOR.c2x] = -anc[_ANCHOR.c1x];
|
anc[@_ANCHOR.c2x] = -anc[_ANCHOR.c1x];
|
||||||
anc[@_ANCHOR.c2y] = -anc[_ANCHOR.c1y];
|
anc[@_ANCHOR.c2y] = -anc[_ANCHOR.c1y];
|
||||||
|
|
||||||
|
} else if(anc[_ANCHOR.ind] == 1) {
|
||||||
|
var _dir = point_direction(0, 0, anc[_ANCHOR.c1x], anc[_ANCHOR.c1y]);
|
||||||
|
var _dis = point_distance(0, 0, anc[_ANCHOR.c2x], anc[_ANCHOR.c2y]);
|
||||||
|
|
||||||
|
anc[@_ANCHOR.c2x] = lengthdir_x(_dis, _dir + 180);
|
||||||
|
anc[@_ANCHOR.c2y] = lengthdir_y(_dis, _dir + 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(key_mod_press(CTRL)) {
|
if(rnd) {
|
||||||
anc[@_ANCHOR.c1x] = round(anc[_ANCHOR.c1x]);
|
anc[@_ANCHOR.c1x] = round(anc[_ANCHOR.c1x]);
|
||||||
anc[@_ANCHOR.c1y] = round(anc[_ANCHOR.c1y]);
|
anc[@_ANCHOR.c1y] = round(anc[_ANCHOR.c1y]);
|
||||||
|
|
||||||
if(!anc[_ANCHOR.ind]) {
|
if(anc[_ANCHOR.ind] < 2) {
|
||||||
anc[@_ANCHOR.c2x] = round(anc[_ANCHOR.c2x]);
|
anc[@_ANCHOR.c2x] = round(anc[_ANCHOR.c2x]);
|
||||||
anc[@_ANCHOR.c2y] = round(anc[_ANCHOR.c2y]);
|
anc[@_ANCHOR.c2y] = round(anc[_ANCHOR.c2y]);
|
||||||
}
|
}
|
||||||
|
@ -334,16 +364,23 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
anc[@_ANCHOR.c2x] = dx - anc[_ANCHOR.x];
|
anc[@_ANCHOR.c2x] = dx - anc[_ANCHOR.x];
|
||||||
anc[@_ANCHOR.c2y] = dy - anc[_ANCHOR.y];
|
anc[@_ANCHOR.c2y] = dy - anc[_ANCHOR.y];
|
||||||
|
|
||||||
if(!anc[_ANCHOR.ind]) {
|
if(anc[_ANCHOR.ind] == 0) {
|
||||||
anc[@_ANCHOR.c1x] = -anc[_ANCHOR.c2x];
|
anc[@_ANCHOR.c1x] = -anc[_ANCHOR.c2x];
|
||||||
anc[@_ANCHOR.c1y] = -anc[_ANCHOR.c2y];
|
anc[@_ANCHOR.c1y] = -anc[_ANCHOR.c2y];
|
||||||
|
|
||||||
|
} else if(anc[_ANCHOR.ind] == 1) {
|
||||||
|
var _dir = point_direction(0, 0, anc[_ANCHOR.c2x], anc[_ANCHOR.c2y]);
|
||||||
|
var _dis = point_distance(0, 0, anc[_ANCHOR.c1x], anc[_ANCHOR.c1y]);
|
||||||
|
|
||||||
|
anc[@_ANCHOR.c1x] = lengthdir_x(_dis, _dir + 180);
|
||||||
|
anc[@_ANCHOR.c1y] = lengthdir_y(_dis, _dir + 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(key_mod_press(CTRL)) {
|
if(rnd) {
|
||||||
anc[@_ANCHOR.c2x] = round(anc[_ANCHOR.c2x]);
|
anc[@_ANCHOR.c2x] = round(anc[_ANCHOR.c2x]);
|
||||||
anc[@_ANCHOR.c2y] = round(anc[_ANCHOR.c2y]);
|
anc[@_ANCHOR.c2y] = round(anc[_ANCHOR.c2y]);
|
||||||
|
|
||||||
if(!anc[_ANCHOR.ind]) {
|
if(anc[_ANCHOR.ind] < 2) {
|
||||||
anc[@_ANCHOR.c1x] = round(anc[_ANCHOR.c1x]);
|
anc[@_ANCHOR.c1x] = round(anc[_ANCHOR.c1x]);
|
||||||
anc[@_ANCHOR.c1y] = round(anc[_ANCHOR.c1y]);
|
anc[@_ANCHOR.c1y] = round(anc[_ANCHOR.c1y]);
|
||||||
}
|
}
|
||||||
|
@ -352,8 +389,9 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
|
|
||||||
if(inp.setValue(anc))
|
if(inp.setValue(anc))
|
||||||
edited = true;
|
edited = true;
|
||||||
|
break;
|
||||||
|
|
||||||
} else if(drag_type == 2) { // pen tools
|
case 2 :
|
||||||
var ox, oy, nx, ny;
|
var ox, oy, nx, ny;
|
||||||
var pxx = (_mx - _x) / _s;
|
var pxx = (_mx - _x) / _s;
|
||||||
var pxy = (_my - _y) / _s;
|
var pxy = (_my - _y) / _s;
|
||||||
|
@ -452,7 +490,10 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(drag_type == 3 || drag_type == 4) { // draw rectangle
|
break;
|
||||||
|
|
||||||
|
case 3 :
|
||||||
|
case 4 :
|
||||||
var minx = min((_mx - _x) / _s, (drag_point_mx - _x) / _s);
|
var minx = min((_mx - _x) / _s, (drag_point_mx - _x) / _s);
|
||||||
var maxx = max((_mx - _x) / _s, (drag_point_mx - _x) / _s);
|
var maxx = max((_mx - _x) / _s, (drag_point_mx - _x) / _s);
|
||||||
var miny = min((_my - _y) / _s, (drag_point_my - _y) / _s);
|
var miny = min((_my - _y) / _s, (drag_point_my - _y) / _s);
|
||||||
|
@ -507,6 +548,8 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
edited |= inputs[input_fix_len + 3].setValue(newAnchor( minx, _cny, 0, _ccy, 0, -_ccy));
|
edited |= inputs[input_fix_len + 3].setValue(newAnchor( minx, _cny, 0, _ccy, 0, -_ccy));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(edited) UNDO_HOLDING = true;
|
if(edited) UNDO_HOLDING = true;
|
||||||
|
@ -516,11 +559,33 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
RENDER_ALL
|
RENDER_ALL
|
||||||
UNDO_HOLDING = false;
|
UNDO_HOLDING = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if(weight_drag != noone) {
|
||||||
|
|
||||||
|
var _mmx = weight_drag_sx + (_mx - weight_drag_mx);
|
||||||
|
var _mmy = weight_drag_sy + (_my - weight_drag_my);
|
||||||
|
|
||||||
|
var _dis = point_distance(weight_drag_sx, weight_drag_sy, _mmx, _mmy) / _s;
|
||||||
|
attributes.weight[weight_drag][1] = _dis;
|
||||||
|
|
||||||
|
updateLength();
|
||||||
|
|
||||||
|
if(mouse_release(mb_left)) {
|
||||||
|
weight_drag = noone;
|
||||||
|
triggerRender();
|
||||||
|
UNDO_HOLDING = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////// DRAW PATH ///////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////// DRAW PATH ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
var _line_hover = -1;
|
var _line_hover = -1;
|
||||||
|
var _weight_hover = -1;
|
||||||
|
var _closet_dist = undefined;
|
||||||
|
var _point_hover = noone;
|
||||||
|
var _point_ratio = 0;
|
||||||
|
|
||||||
var anchor_hover = -1;
|
var anchor_hover = -1;
|
||||||
var hover_type = 0;
|
var hover_type = 0;
|
||||||
|
|
||||||
|
@ -530,7 +595,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
var minx = 99999, miny = 99999;
|
var minx = 99999, miny = 99999;
|
||||||
var maxx = -99999, maxy = -99999;
|
var maxx = -99999, maxy = -99999;
|
||||||
|
|
||||||
if(isUsingTool(4) || isUsingTool(5)) {
|
if(_tooln == "Rectangle path" || _tooln == "Circle path") {
|
||||||
draw_set_color(COLORS._main_icon);
|
draw_set_color(COLORS._main_icon);
|
||||||
|
|
||||||
if(drag_point > -1) {
|
if(drag_point > -1) {
|
||||||
|
@ -587,33 +652,100 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!array_empty(anchors)) {
|
if(!array_empty(anchors)) {
|
||||||
draw_set_color(isUsingTool(0)? COLORS._main_icon : COLORS._main_accent);
|
draw_set_color(_tooln == "Transform"? COLORS._main_icon : COLORS._main_accent);
|
||||||
|
|
||||||
|
var _ox = 0, _oy = 0, _ow = 0;
|
||||||
|
var _nx = 0, _ny = 0, _nw = 0;
|
||||||
|
|
||||||
|
var _ow1x = 0, _ow1y = 0, _ow2x = 0, _ow2y = 0;
|
||||||
|
var _nw1x = 0, _nw1y = 0, _nw2x = 0, _nw2y = 0;
|
||||||
|
|
||||||
for( var i = 0, n = array_length(segments); i < n; i++ ) { // draw path
|
for( var i = 0, n = array_length(segments); i < n; i++ ) { // draw path
|
||||||
var _seg = segments[i];
|
var _seg = segments[i];
|
||||||
var _ox = 0, _oy = 0, _nx = 0, _ny = 0, p = 0;
|
var p = 0;
|
||||||
|
|
||||||
for( var j = 0, m = array_length(_seg); j < m; j += 2 ) {
|
var _amo = array_length(_seg);
|
||||||
|
var _rat_s = lengthRatio[i];
|
||||||
|
var _rat_e = lengthRatio[i + 1];
|
||||||
|
var _wdir = point_direction(_seg[0], _seg[1], _seg[2], _seg[3]);
|
||||||
|
|
||||||
|
for( var j = 0; j < _amo; j += 2 ) {
|
||||||
_nx = _x + _seg[j + 0] * _s;
|
_nx = _x + _seg[j + 0] * _s;
|
||||||
_ny = _y + _seg[j + 1] * _s;
|
_ny = _y + _seg[j + 1] * _s;
|
||||||
|
|
||||||
minx = min(minx, _nx); maxx = max(maxx, _nx);
|
minx = min(minx, _nx); maxx = max(maxx, _nx);
|
||||||
miny = min(miny, _ny); maxy = max(maxy, _ny);
|
miny = min(miny, _ny); maxy = max(maxy, _ny);
|
||||||
|
|
||||||
|
var _rat = round(lerp(_rat_s, _rat_e, j / _amo) * 100);
|
||||||
|
_nw = weightRatio[clamp(_rat, 0, array_length(weightRatio) - 1)];
|
||||||
|
|
||||||
|
if(_tooln == "Weight edit") {
|
||||||
|
if(j) _wdir = point_direction(_ox, _oy, _nx, _ny);
|
||||||
|
_nw1x = _nx + lengthdir_x(_nw, _wdir + 90);
|
||||||
|
_nw1y = _ny + lengthdir_y(_nw, _wdir + 90);
|
||||||
|
_nw2x = _nx + lengthdir_x(_nw, _wdir - 90);
|
||||||
|
_nw2y = _ny + lengthdir_y(_nw, _wdir - 90);
|
||||||
|
|
||||||
|
if(i == 0 && j == 0) {
|
||||||
|
draw_set_color(COLORS._main_icon);
|
||||||
|
draw_line(_nx, _ny, _nw1x, _nw1y);
|
||||||
|
draw_line(_nx, _ny, _nw2x, _nw2y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(j) {
|
if(j) {
|
||||||
if(hover && (key_mod_press(CTRL) || isUsingTool(1)) && distance_to_line(_mx, _my, _ox, _oy, _nx, _ny) < 4)
|
if(hover) {
|
||||||
_line_hover = i;
|
var _p = point_to_line(_mx, _my, _ox, _oy, _nx, _ny);
|
||||||
draw_line_width(_ox, _oy, _nx, _ny, 1 + 2 * (line_hover == i));
|
var _d = point_distance(_mx, _my, _p[0], _p[1]);
|
||||||
|
|
||||||
|
if(_d < 16 && (_closet_dist == undefined || _d < _closet_dist)) {
|
||||||
|
_closet_dist = _d;
|
||||||
|
_point_hover = _p;
|
||||||
|
_point_ratio = _rat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_d < 4) _line_hover = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_tooln == "Weight edit") {
|
||||||
|
draw_set_color(COLORS._main_accent);
|
||||||
|
draw_line(_ox, _oy, _nx, _ny);
|
||||||
|
|
||||||
|
draw_set_color(COLORS._main_icon);
|
||||||
|
draw_line(_ow1x, _ow1y, _nw1x, _nw1y);
|
||||||
|
draw_line(_ow2x, _ow2y, _nw2x, _nw2y);
|
||||||
|
|
||||||
|
if(i == n - 1 && j + 2 >= _amo) {
|
||||||
|
draw_set_color(COLORS._main_icon);
|
||||||
|
draw_line(_nx, _ny, _nw1x, _nw1y);
|
||||||
|
draw_line(_nx, _ny, _nw2x, _nw2y);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
draw_line_width(_ox, _oy, _nx, _ny, 1 + (line_hover == i));
|
||||||
}
|
}
|
||||||
|
|
||||||
_ox = _nx;
|
_ox = _nx;
|
||||||
_oy = _ny;
|
_oy = _ny;
|
||||||
|
|
||||||
|
_ow = _nw;
|
||||||
|
_ow1x = _nw1x;
|
||||||
|
_ow1y = _nw1y;
|
||||||
|
_ow2x = _nw2x;
|
||||||
|
_ow2y = _nw2y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region draw anchor
|
var _showAnchor = hover != -1;
|
||||||
if(hover != -1 && !isUsingTool(0))
|
switch(_tooln) {
|
||||||
for(var i = 0; i < ansize; i++) {
|
case "Transform" :
|
||||||
|
case "Weight edit" :
|
||||||
|
_showAnchor = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_showAnchor)
|
||||||
|
for(var i = 0; i < ansize; i++) { // draw anchor
|
||||||
var _a = anchors[i];
|
var _a = anchors[i];
|
||||||
var xx = _x + _a[0] * _s;
|
var xx = _x + _a[0] * _s;
|
||||||
var yy = _y + _a[1] * _s;
|
var yy = _y + _a[1] * _s;
|
||||||
|
@ -661,15 +793,41 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
hover_type = -1;
|
hover_type = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
if(_tooln == "Weight edit") {
|
||||||
|
var _w = attributes.weight;
|
||||||
|
var _wd = 12;
|
||||||
|
|
||||||
|
for( var i = 0, n = array_length(_w); i < n; i++ ) {
|
||||||
|
var _wg = _w[i];
|
||||||
|
var _wrat = _wg[0];
|
||||||
|
var _wp = getPointDistance(_wrat / 100 * lengthTotal);
|
||||||
|
|
||||||
|
var _wx = _x + _wp.x * _s;
|
||||||
|
var _wy = _y + _wp.y * _s;
|
||||||
|
var _pd = point_distance(_mx, _my, _wx, _wy);
|
||||||
|
|
||||||
|
if(_pd < _wd) {
|
||||||
|
_weight_hover = i;
|
||||||
|
_wd = _pd;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _sel = weight_hover == i || weight_drag == i;
|
||||||
|
draw_set_color(_sel? COLORS._main_accent : COLORS._main_icon_light);
|
||||||
|
draw_circle(_wx, _wy, _sel? 5 : 3, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hover == -1) return false;
|
if(hover == -1) return false;
|
||||||
line_hover = _line_hover;
|
line_hover = _line_hover;
|
||||||
|
weight_hover = _weight_hover;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////// TOOLS ///////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////// TOOLS ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
if(isUsingTool(0)) { // transform tools
|
switch(_tooln) {
|
||||||
|
case "Transform" :
|
||||||
var hov = 0;
|
var hov = 0;
|
||||||
if(hover && point_in_circle(_mx, _my, minx, miny, 8)) hov = 1;
|
if(hover && point_in_circle(_mx, _my, minx, miny, 8)) hov = 1;
|
||||||
else if(hover && point_in_circle(_mx, _my, maxx, miny, 8)) hov = 2;
|
else if(hover && point_in_circle(_mx, _my, maxx, miny, 8)) hov = 2;
|
||||||
|
@ -695,111 +853,10 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
transform_cx = (transform_minx + transform_maxx) / 2;
|
transform_cx = (transform_minx + transform_maxx) / 2;
|
||||||
transform_cy = (transform_miny + transform_maxy) / 2;
|
transform_cy = (transform_miny + transform_maxy) / 2;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
} else if(isUsingTool(3)) { //pen tools
|
case "Anchor add / remove" :
|
||||||
draw_sprite_ui_uniform(THEME.path_tools_draw, 0, _mx + 16, _my + 16);
|
draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
|
||||||
var replace = tool_pathDrawer.attribute.create;
|
|
||||||
if(replace) {
|
|
||||||
while(array_length(inputs) > input_fix_len)
|
|
||||||
array_delete(inputs, input_fix_len, 1);
|
|
||||||
resetDisplayList();
|
|
||||||
}
|
|
||||||
|
|
||||||
drag_point = 0;
|
|
||||||
drag_type = 2;
|
|
||||||
drag_points = [ [ (_mx - _x) / _s, (_my - _y) / _s ] ];
|
|
||||||
drag_point_mx = (_mx - _x) / _s;
|
|
||||||
drag_point_my = (_my - _y) / _s;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if(isUsingTool(4) || isUsingTool(5)) { // shape tools
|
|
||||||
draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 16, _my + 16);
|
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
|
||||||
while(array_length(inputs) > input_fix_len)
|
|
||||||
array_delete(inputs, input_fix_len, 1);
|
|
||||||
resetDisplayList();
|
|
||||||
|
|
||||||
drag_point = 0;
|
|
||||||
drag_type = isUsingTool(4)? 3 : 4;
|
|
||||||
drag_point_mx = _mx;
|
|
||||||
drag_point_my = _my;
|
|
||||||
inputs[1].setValue(true);
|
|
||||||
|
|
||||||
repeat(4)
|
|
||||||
createNewInput(value_snap((_mx - _x) / _s, _snx), value_snap((_my - _y) / _s, _sny));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if(anchor_hover != -1) { // no tool, dragging existing point
|
|
||||||
var _a/*:_ANCHOR*/ = array_clone(getInputData(input_fix_len + anchor_hover));
|
|
||||||
if(isUsingTool(2) && hover_type == 0) {
|
|
||||||
draw_sprite_ui_uniform(THEME.cursor_path_anchor, 0, _mx + 16, _my + 16);
|
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
|
||||||
if(_a[_ANCHOR.c1x] != 0 || _a[_ANCHOR.c1y] != 0 || _a[_ANCHOR.c2x] != 0 || _a[_ANCHOR.c2y] != 0) {
|
|
||||||
_a[@_ANCHOR.c1x] = 0;
|
|
||||||
_a[@_ANCHOR.c1y] = 0;
|
|
||||||
_a[@_ANCHOR.c2x] = 0;
|
|
||||||
_a[@_ANCHOR.c2y] = 0;
|
|
||||||
_a[@_ANCHOR.ind] = false;
|
|
||||||
inputs[input_fix_len + anchor_hover].setValue(_a);
|
|
||||||
} else {
|
|
||||||
_a[@_ANCHOR.c1x] = -8;
|
|
||||||
_a[@_ANCHOR.c1y] = 0;
|
|
||||||
_a[@_ANCHOR.c2x] = 8;
|
|
||||||
_a[@_ANCHOR.c2y] = 0;
|
|
||||||
_a[@_ANCHOR.ind] = false;
|
|
||||||
|
|
||||||
drag_point = anchor_hover;
|
|
||||||
drag_type = 1;
|
|
||||||
drag_point_mx = _mx;
|
|
||||||
drag_point_my = _my;
|
|
||||||
drag_point_sx = _a[_ANCHOR.x];
|
|
||||||
drag_point_sy = _a[_ANCHOR.y];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(hover_type == 0 && key_mod_press(SHIFT)) { //remove
|
|
||||||
draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 16, _my + 16);
|
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
|
||||||
var _indx = input_fix_len + anchor_hover;
|
|
||||||
recordAction(ACTION_TYPE.array_delete, inputs, [ inputs[_indx], _indx, "remove path anchor point" ]);
|
|
||||||
|
|
||||||
array_delete(inputs, _indx, 1);
|
|
||||||
resetDisplayList();
|
|
||||||
doUpdate();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
draw_sprite_ui_uniform(THEME.cursor_path_move, 0, _mx + 16, _my + 16);
|
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
|
||||||
if(isUsingTool(2)) {
|
|
||||||
_a[@_ANCHOR.ind] = true;
|
|
||||||
inputs[input_fix_len + anchor_hover].setValue(_a);
|
|
||||||
}
|
|
||||||
|
|
||||||
drag_point = anchor_hover;
|
|
||||||
drag_type = hover_type;
|
|
||||||
drag_point_mx = _mx;
|
|
||||||
drag_point_my = _my;
|
|
||||||
drag_point_sx = _a[_ANCHOR.x];
|
|
||||||
drag_point_sy = _a[_ANCHOR.y];
|
|
||||||
|
|
||||||
if(hover_type == 1) {
|
|
||||||
drag_point_sx = _a[_ANCHOR.x] + _a[_ANCHOR.c1x];
|
|
||||||
drag_point_sy = _a[_ANCHOR.y] + _a[_ANCHOR.c1y];
|
|
||||||
|
|
||||||
} else if(hover_type == -1) {
|
|
||||||
drag_point_sx = _a[_ANCHOR.x] + _a[_ANCHOR.c2x];
|
|
||||||
drag_point_sy = _a[_ANCHOR.y] + _a[_ANCHOR.c2y];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if(key_mod_press(CTRL) || isUsingTool(1)) { // anchor edit
|
|
||||||
draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 16, _my + 16);
|
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
if(mouse_press(mb_left, active)) {
|
||||||
var ind = array_length(inputs);
|
var ind = array_length(inputs);
|
||||||
|
@ -826,6 +883,168 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
|
|
||||||
RENDER_ALL
|
RENDER_ALL
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Draw path" :
|
||||||
|
draw_sprite_ui_uniform(THEME.path_tools_draw, 0, _mx + 16, _my + 16);
|
||||||
|
|
||||||
|
if(mouse_press(mb_left, active)) {
|
||||||
|
var replace = tool_pathDrawer.attribute.create;
|
||||||
|
if(replace) {
|
||||||
|
while(array_length(inputs) > input_fix_len)
|
||||||
|
array_delete(inputs, input_fix_len, 1);
|
||||||
|
resetDisplayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
drag_point = 0;
|
||||||
|
drag_type = 2;
|
||||||
|
drag_points = [ [ (_mx - _x) / _s, (_my - _y) / _s ] ];
|
||||||
|
drag_point_mx = (_mx - _x) / _s;
|
||||||
|
drag_point_my = (_my - _y) / _s;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Rectangle path" :
|
||||||
|
case "Circle path" :
|
||||||
|
draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
|
if(mouse_press(mb_left, active)) {
|
||||||
|
while(array_length(inputs) > input_fix_len)
|
||||||
|
array_delete(inputs, input_fix_len, 1);
|
||||||
|
resetDisplayList();
|
||||||
|
|
||||||
|
drag_point = 0;
|
||||||
|
drag_type = isUsingTool(4)? 3 : 4;
|
||||||
|
drag_point_mx = _mx;
|
||||||
|
drag_point_my = _my;
|
||||||
|
inputs[1].setValue(true);
|
||||||
|
|
||||||
|
repeat(4)
|
||||||
|
createNewInput(value_snap((_mx - _x) / _s, _snx), value_snap((_my - _y) / _s, _sny));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "Weight edit" :
|
||||||
|
if(_point_hover != noone) {
|
||||||
|
|
||||||
|
if(_weight_hover == -1) {
|
||||||
|
draw_set_color(COLORS._main_accent);
|
||||||
|
draw_circle(_point_hover[0], _point_hover[1], 4, false);
|
||||||
|
|
||||||
|
} else if(_weight_hover != -1 && key_mod_press(SHIFT)) {
|
||||||
|
draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
|
if(mouse_press(mb_left, active)) {
|
||||||
|
if(_weight_hover == 0 || _weight_hover == array_length(attributes.weight) - 1)
|
||||||
|
attributes.weight[_weight_hover][0] = 1;
|
||||||
|
else
|
||||||
|
array_delete(attributes.weight, _weight_hover, 1);
|
||||||
|
triggerRender();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mouse_press(mb_left, active)) {
|
||||||
|
if(array_empty(attributes.weight)) attributes.weight = [ [ 0, 1 ], [ 100, 1 ] ];
|
||||||
|
var _w = attributes.weight;
|
||||||
|
|
||||||
|
if(_weight_hover != -1) {
|
||||||
|
weight_drag = _weight_hover;
|
||||||
|
} else {
|
||||||
|
for( var i = 0, n = array_length(_w) - 1; i < n; i++ ) {
|
||||||
|
if(_point_ratio > _w[i + 1][0]) continue;
|
||||||
|
|
||||||
|
array_insert(_w, i + 1, [ _point_ratio, 1 ]);
|
||||||
|
weight_drag = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
weight_drag_sx = _point_hover[0];
|
||||||
|
weight_drag_sy = _point_hover[1];
|
||||||
|
weight_drag_mx = _mx;
|
||||||
|
weight_drag_my = _my;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default :
|
||||||
|
if(anchor_hover == -1) break;
|
||||||
|
|
||||||
|
var _a/*:_ANCHOR*/ = array_clone(getInputData(input_fix_len + anchor_hover));
|
||||||
|
|
||||||
|
if(_tooln == "Edit Control point" && hover_type == 0) { // add / remove anchor point
|
||||||
|
draw_sprite_ui_uniform(THEME.cursor_path_anchor, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
|
if(mouse_press(mb_left, active)) {
|
||||||
|
if(_a[_ANCHOR.c1x] != 0 || _a[_ANCHOR.c1y] != 0 || _a[_ANCHOR.c2x] != 0 || _a[_ANCHOR.c2y] != 0) {
|
||||||
|
_a[@_ANCHOR.c1x] = 0;
|
||||||
|
_a[@_ANCHOR.c1y] = 0;
|
||||||
|
_a[@_ANCHOR.c2x] = 0;
|
||||||
|
_a[@_ANCHOR.c2y] = 0;
|
||||||
|
_a[@_ANCHOR.ind] = 0;
|
||||||
|
inputs[input_fix_len + anchor_hover].setValue(_a);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_a[@_ANCHOR.c1x] = -8;
|
||||||
|
_a[@_ANCHOR.c1y] = 0;
|
||||||
|
_a[@_ANCHOR.c2x] = 8;
|
||||||
|
_a[@_ANCHOR.c2y] = 0;
|
||||||
|
_a[@_ANCHOR.ind] = 0;
|
||||||
|
|
||||||
|
drag_point = anchor_hover;
|
||||||
|
drag_type = 1;
|
||||||
|
drag_point_mx = _mx;
|
||||||
|
drag_point_my = _my;
|
||||||
|
drag_point_sx = _a[_ANCHOR.x];
|
||||||
|
drag_point_sy = _a[_ANCHOR.y];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if(hover_type == 0 && key_mod_press(SHIFT)) { //remove
|
||||||
|
draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
|
if(mouse_press(mb_left, active)) {
|
||||||
|
var _indx = input_fix_len + anchor_hover;
|
||||||
|
recordAction(ACTION_TYPE.array_delete, inputs, [ inputs[_indx], _indx, "remove path anchor point" ]);
|
||||||
|
|
||||||
|
array_delete(inputs, _indx, 1);
|
||||||
|
resetDisplayList();
|
||||||
|
doUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
var _spr = THEME.cursor_path_move;
|
||||||
|
if(_tooln == "Edit Control point")
|
||||||
|
_spr = key_mod_press(SHIFT)? THEME.cursor_path_anchor_detach : THEME.cursor_path_anchor_unmirror;
|
||||||
|
|
||||||
|
draw_sprite_ui_uniform(_spr, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
|
if(mouse_press(mb_left, active)) {
|
||||||
|
if(_tooln == "Edit Control point") {
|
||||||
|
_a[@_ANCHOR.ind] = key_mod_press(SHIFT)? 2 : 1;
|
||||||
|
inputs[input_fix_len + anchor_hover].setValue(_a);
|
||||||
|
}
|
||||||
|
|
||||||
|
drag_point = anchor_hover;
|
||||||
|
drag_type = hover_type;
|
||||||
|
drag_point_mx = _mx;
|
||||||
|
drag_point_my = _my;
|
||||||
|
drag_point_sx = _a[_ANCHOR.x];
|
||||||
|
drag_point_sy = _a[_ANCHOR.y];
|
||||||
|
|
||||||
|
if(hover_type == 1) {
|
||||||
|
drag_point_sx = _a[_ANCHOR.x] + _a[_ANCHOR.c1x];
|
||||||
|
drag_point_sy = _a[_ANCHOR.y] + _a[_ANCHOR.c1y];
|
||||||
|
|
||||||
|
} else if(hover_type == -1) {
|
||||||
|
drag_point_sx = _a[_ANCHOR.x] + _a[_ANCHOR.c2x];
|
||||||
|
drag_point_sy = _a[_ANCHOR.y] + _a[_ANCHOR.c2y];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -879,6 +1098,34 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
lengthAccs[i] = lengthTotal;
|
lengthAccs[i] = lengthTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lengthRatio = array_create(ansize + 1);
|
||||||
|
lengthRatio[0] = 0;
|
||||||
|
for( var i = 0; i < con; i++ )
|
||||||
|
lengthRatio[i + 1] = lengthAccs[i] / lengthTotal;
|
||||||
|
|
||||||
|
var _w = attributes.weight;
|
||||||
|
|
||||||
|
if(array_empty(_w)) weightRatio = array_map(weightRatio, function(i) /*=>*/ {return 1});
|
||||||
|
else if(array_length(_w) == 1) weightRatio = array_map(weightRatio, function(i) /*=>*/ {return attributes.weight[0][1]});
|
||||||
|
else {
|
||||||
|
var _wi = 0;
|
||||||
|
var _wamo = array_length(_w);
|
||||||
|
var _amo = 100;
|
||||||
|
|
||||||
|
var _wf = _w[_wi + 0];
|
||||||
|
var _wt = _w[_wi + 1];
|
||||||
|
|
||||||
|
for( var i = 0; i <= _amo; i++ ) {
|
||||||
|
if(i < _amo && i == _wt[0]) {
|
||||||
|
_wi++;
|
||||||
|
_wf = _w[_wi + 0];
|
||||||
|
_wt = _w[_wi + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
weightRatio[i] = lerp(_wf[1], _wt[1], lerp_smooth((i - _wf[0]) / (_wt[0] - _wf[0])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Surface generate
|
// Surface generate
|
||||||
|
|
||||||
var pad = min(8, abs(boundary.maxx - boundary.minx) * 0.1, abs(boundary.maxy - boundary.miny) * 0.1);
|
var pad = min(8, abs(boundary.maxx - boundary.minx) * 0.1, abs(boundary.maxy - boundary.miny) * 0.1);
|
||||||
|
@ -935,15 +1182,17 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
static getAccuLength = function() { return lengthAccs; }
|
static getAccuLength = function() { return lengthAccs; }
|
||||||
|
|
||||||
static getPointDistance = function(_dist, _ind = 0, out = undefined) {
|
static getPointDistance = function(_dist, _ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
if(array_empty(lengths)) return out;
|
if(array_empty(lengths)) return out;
|
||||||
|
|
||||||
|
out.weight = 1;
|
||||||
var _cKey = _dist;
|
var _cKey = _dist;
|
||||||
|
|
||||||
if(ds_map_exists(cached_pos, _cKey)) {
|
if(ds_map_exists(cached_pos, _cKey)) {
|
||||||
var _cachep = cached_pos[? _cKey];
|
var _cachep = cached_pos[? _cKey];
|
||||||
out.x = _cachep.x;
|
out.x = _cachep.x;
|
||||||
out.y = _cachep.y;
|
out.y = _cachep.y;
|
||||||
|
out.weight = _cachep.weight;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -966,16 +1215,21 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
var _t = _l == 0? 0 : _dist / _l;
|
var _t = _l == 0? 0 : _dist / _l;
|
||||||
|
var _rat = lerp(lengthRatio[i], lengthRatio[i + 1], _t) * 100;
|
||||||
|
var _nw = array_get_decimal(weightRatio, _rat);
|
||||||
|
|
||||||
if(_a0[4] == 0 && _a0[5] == 0 && _a1[2] == 0 && _a1[3] == 0) {
|
if(_a0[4] == 0 && _a0[5] == 0 && _a1[2] == 0 && _a1[3] == 0) {
|
||||||
out.x = lerp(_a0[0], _a1[0], _t);
|
out.x = lerp(_a0[0], _a1[0], _t);
|
||||||
out.y = lerp(_a0[1], _a1[1], _t);
|
out.y = lerp(_a0[1], _a1[1], _t);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
out.x = eval_bezier_x(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]);
|
out.x = eval_bezier_x(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]);
|
||||||
out.y = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]);
|
out.y = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
cached_pos[? _cKey] = out.clone();
|
out.weight = _nw;
|
||||||
|
|
||||||
|
cached_pos[? _cKey] = new __vec2P(out.x, out.y, _nw);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,19 +1242,19 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPointSegment = function(_rat) {
|
static getPointSegment = function(_rat) {
|
||||||
if(array_empty(lengths)) return new __vec2();
|
if(array_empty(lengths)) return new __vec2P();
|
||||||
|
|
||||||
var loop = getInputData(1);
|
var loop = getInputData(1);
|
||||||
var ansize = array_length(inputs) - input_fix_len;
|
var ansize = array_length(inputs) - input_fix_len;
|
||||||
|
|
||||||
if(_rat < 0) return new __vec2(anchors[0][0], anchors[0][1]);
|
if(_rat < 0) return new __vec2P(anchors[0][0], anchors[0][1]);
|
||||||
|
|
||||||
_rat = safe_mod(_rat, ansize);
|
_rat = safe_mod(_rat, ansize);
|
||||||
var _i0 = clamp(floor(_rat), 0, ansize - 1);
|
var _i0 = clamp(floor(_rat), 0, ansize - 1);
|
||||||
var _i1 = (_i0 + 1) % ansize;
|
var _i1 = (_i0 + 1) % ansize;
|
||||||
var _t = frac(_rat);
|
var _t = frac(_rat);
|
||||||
|
|
||||||
if(_i1 >= ansize && !loop) return new __vec2(anchors[ansize - 1][0], anchors[ansize - 1][1]);
|
if(_i1 >= ansize && !loop) return new __vec2P(anchors[ansize - 1][0], anchors[ansize - 1][1]);
|
||||||
|
|
||||||
var _a0 = anchors[_i0];
|
var _a0 = anchors[_i0];
|
||||||
var _a1 = anchors[_i1];
|
var _a1 = anchors[_i1];
|
||||||
|
@ -1014,7 +1268,7 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
py = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]);
|
py = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new __vec2(px, py);
|
return new __vec2P(px, py);
|
||||||
}
|
}
|
||||||
|
|
||||||
static update = function(frame = CURRENT_FRAME) {
|
static update = function(frame = CURRENT_FRAME) {
|
||||||
|
|
|
@ -353,7 +353,7 @@ function Node_Path_3D(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
||||||
if(anchor_hover != -1) { // no tool, dragging existing point
|
if(anchor_hover != -1) { // no tool, dragging existing point
|
||||||
var _a = array_clone(getInputData(input_fix_len + anchor_hover));
|
var _a = array_clone(getInputData(input_fix_len + anchor_hover));
|
||||||
if(isUsingTool(2) && hover_type == 0) {
|
if(isUsingTool(2) && hover_type == 0) {
|
||||||
draw_sprite_ui_uniform(THEME.cursor_path_anchor, 0, _mx + 16, _my + 16);
|
draw_sprite_ui_uniform(THEME.cursor_path_anchor, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
if(mouse_press(mb_left, active)) {
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ function Node_Path_3D(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(hover_type == 0 && key_mod_press(SHIFT)) { //remove
|
} else if(hover_type == 0 && key_mod_press(SHIFT)) { //remove
|
||||||
draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 16, _my + 16);
|
draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
if(mouse_press(mb_left, active)) {
|
||||||
var _indx = input_fix_len + anchor_hover;
|
var _indx = input_fix_len + anchor_hover;
|
||||||
|
@ -398,7 +398,7 @@ function Node_Path_3D(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
||||||
doUpdate();
|
doUpdate();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
draw_sprite_ui_uniform(THEME.cursor_path_move, 0, _mx + 16, _my + 16);
|
draw_sprite_ui_uniform(THEME.cursor_path_move, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
if(mouse_press(mb_left, active)) {
|
||||||
if(isUsingTool(2)) {
|
if(isUsingTool(2)) {
|
||||||
|
@ -436,7 +436,7 @@ function Node_Path_3D(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(key_mod_press(CTRL) || isUsingTool(1)) { // anchor edit
|
} else if(key_mod_press(CTRL) || isUsingTool(1)) { // anchor edit
|
||||||
draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 16, _my + 16);
|
draw_sprite_ui_uniform(THEME.cursor_path_add, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
if(mouse_press(mb_left, active)) {
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ function Node_Path_Array(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
ind -= lc;
|
ind -= lc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new __vec2();
|
return new __vec2P();
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPointDistance = function(_dist, ind = 0) {
|
static getPointDistance = function(_dist, ind = 0) {
|
||||||
|
@ -81,7 +81,7 @@ function Node_Path_Array(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
ind -= lc;
|
ind -= lc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new __vec2();
|
return new __vec2P();
|
||||||
}
|
}
|
||||||
|
|
||||||
static getBoundary = function(ind = 0) {
|
static getBoundary = function(ind = 0) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ function Node_Path_Bake(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
||||||
path_amount = _amo;
|
path_amount = _amo;
|
||||||
var _segs = array_create(_amo);
|
var _segs = array_create(_amo);
|
||||||
|
|
||||||
var _p = new __vec2();
|
var _p = new __vec2P();
|
||||||
|
|
||||||
for( var i = 0; i < _amo; i++ ) {
|
for( var i = 0; i < _amo; i++ ) {
|
||||||
var _len = _path.getLength(i);
|
var _len = _path.getLength(i);
|
||||||
|
|
|
@ -19,7 +19,7 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
|
|
||||||
cached_pos = ds_map_create();
|
cached_pos = ds_map_create();
|
||||||
|
|
||||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
var _p0 = getInputData(0);
|
var _p0 = getInputData(0);
|
||||||
var _p1 = getInputData(1);
|
var _p1 = getInputData(1);
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
var _len = getLength(_amo);
|
var _len = getLength(_amo);
|
||||||
var _stp = 1 / clamp(_len * _s, 1, 64);
|
var _stp = 1 / clamp(_len * _s, 1, 64);
|
||||||
var ox, oy, nx, ny;
|
var ox, oy, nx, ny;
|
||||||
var _p = new __vec2();
|
var _p = new __vec2P();
|
||||||
|
|
||||||
for( var j = 0; j < 1; j += _stp ) {
|
for( var j = 0; j < 1; j += _stp ) {
|
||||||
_p = getPointRatio(j, i, _p);
|
_p = getPointRatio(j, i, _p);
|
||||||
|
@ -46,14 +46,14 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
oy = ny;
|
oy = ny;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getLineCount = function() { #region
|
static getLineCount = function() {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
return struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
return struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getSegmentCount = function(ind = 0) { #region
|
static getSegmentCount = function(ind = 0) {
|
||||||
var _path1 = getInputData(0);
|
var _path1 = getInputData(0);
|
||||||
var _path2 = getInputData(1);
|
var _path2 = getInputData(1);
|
||||||
var _lerp = getInputData(2);
|
var _lerp = getInputData(2);
|
||||||
|
@ -66,9 +66,9 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
if(!p1 && p2) return _path2.getSegmentCount(ind);
|
if(!p1 && p2) return _path2.getSegmentCount(ind);
|
||||||
|
|
||||||
return max(_path1.getSegmentCount(ind), _path2.getSegmentCount(ind));
|
return max(_path1.getSegmentCount(ind), _path2.getSegmentCount(ind));
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getLength = function(ind = 0) { #region
|
static getLength = function(ind = 0) {
|
||||||
var _path1 = getInputData(0);
|
var _path1 = getInputData(0);
|
||||||
var _path2 = getInputData(1);
|
var _path2 = getInputData(1);
|
||||||
var _lerp = getInputData(2);
|
var _lerp = getInputData(2);
|
||||||
|
@ -84,9 +84,9 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
var _p2 = _path2.getLength(ind);
|
var _p2 = _path2.getLength(ind);
|
||||||
|
|
||||||
return lerp(_p1, _p2, _lerp);
|
return lerp(_p1, _p2, _lerp);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getAccuLength = function(ind = 0) { #region
|
static getAccuLength = function(ind = 0) {
|
||||||
var _path1 = getInputData(0);
|
var _path1 = getInputData(0);
|
||||||
var _path2 = getInputData(1);
|
var _path2 = getInputData(1);
|
||||||
var _lerp = getInputData(2);
|
var _lerp = getInputData(2);
|
||||||
|
@ -112,16 +112,17 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getPointRatio = function(_rat, ind = 0, out = undefined) { #region
|
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
|
var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
|
||||||
if(ds_map_exists(cached_pos, _cKey)) {
|
if(ds_map_exists(cached_pos, _cKey)) {
|
||||||
var _p = cached_pos[? _cKey];
|
var _p = cached_pos[? _cKey];
|
||||||
out.x = _p.x;
|
out.x = _p.x;
|
||||||
out.y = _p.y;
|
out.y = _p.y;
|
||||||
|
out.weight = _p.weight;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,15 +142,16 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
|
|
||||||
out.x = lerp(_p1.x, _p2.x, _lerp);
|
out.x = lerp(_p1.x, _p2.x, _lerp);
|
||||||
out.y = lerp(_p1.y, _p2.y, _lerp);
|
out.y = lerp(_p1.y, _p2.y, _lerp);
|
||||||
|
out.weight = lerp(_p1.weight, _p2.weight, _lerp);
|
||||||
|
|
||||||
cached_pos[? _cKey] = out.clone();
|
cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(ind), ind, out); }
|
static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(ind), ind, out); }
|
||||||
|
|
||||||
static getBoundary = function(ind = 0) { #region
|
static getBoundary = function(ind = 0) {
|
||||||
var _path1 = getInputData(0);
|
var _path1 = getInputData(0);
|
||||||
var _path2 = getInputData(1);
|
var _path2 = getInputData(1);
|
||||||
var _lerp = getInputData(2);
|
var _lerp = getInputData(2);
|
||||||
|
@ -165,15 +167,15 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
var _p2 = _path2.getBoundary(ind);
|
var _p2 = _path2.getBoundary(ind);
|
||||||
|
|
||||||
return _p1.lerpTo(_p2, _lerp);
|
return _p1.lerpTo(_p2, _lerp);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static update = function() { #region
|
static update = function() {
|
||||||
ds_map_clear(cached_pos);
|
ds_map_clear(cached_pos);
|
||||||
outputs[0].setValue(self);
|
outputs[0].setValue(self);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||||
var bbox = drawGetBbox(xx, yy, _s);
|
var bbox = drawGetBbox(xx, yy, _s);
|
||||||
draw_sprite_fit(s_node_path_blend, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
draw_sprite_fit(s_node_path_blend, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
||||||
} #endregion
|
}
|
||||||
}
|
}
|
|
@ -31,14 +31,14 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
cached_pos = ds_map_create();
|
cached_pos = ds_map_create();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
var _smt = getInputData(2);
|
var _smt = getInputData(2);
|
||||||
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||||
|
|
||||||
var _amo = array_length(anchors);
|
var _amo = array_length(anchors);
|
||||||
var ox, oy, nx, ny;
|
var ox, oy, nx, ny;
|
||||||
var _p = new __vec2();
|
var _p = new __vec2P();
|
||||||
|
|
||||||
draw_set_color(COLORS._main_icon);
|
draw_set_color(COLORS._main_icon);
|
||||||
for( var i = 0, n = _amo; i < n; i++ ) {
|
for( var i = 0, n = _amo; i < n; i++ ) {
|
||||||
|
@ -69,7 +69,7 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getLineCount = function() { return getInputData(1); }
|
static getLineCount = function() { return getInputData(1); }
|
||||||
|
|
||||||
|
@ -83,14 +83,15 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
|
|
||||||
static getPointRatio = function(_rat, ind = 0, out = undefined) { return getPointDistance(clamp(_rat, 0, 1) * getLength(ind), ind, out); }
|
static getPointRatio = function(_rat, ind = 0, out = undefined) { return getPointDistance(clamp(_rat, 0, 1) * getLength(ind), ind, out); }
|
||||||
|
|
||||||
static getPointDistance = function(_dist, ind = 0, out = undefined) { #region
|
static getPointDistance = function(_dist, ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _cKey = $"{string_format(_dist, 0, 6)},{ind}";
|
var _cKey = $"{string_format(_dist, 0, 6)},{ind}";
|
||||||
if(ds_map_exists(cached_pos, _cKey)) {
|
if(ds_map_exists(cached_pos, _cKey)) {
|
||||||
var _p = cached_pos[? _cKey];
|
var _p = cached_pos[? _cKey];
|
||||||
out.x = _p.x;
|
out.x = _p.x;
|
||||||
out.y = _p.y;
|
out.y = _p.y;
|
||||||
|
out.weight = _p.weight;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +104,7 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
out.x = _p[0];
|
out.x = _p[0];
|
||||||
out.y = _p[1];
|
out.y = _p[1];
|
||||||
|
|
||||||
cached_pos[? _cKey] = out.clone();
|
cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +118,7 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
out.x = _p[0];
|
out.x = _p[0];
|
||||||
out.y = _p[1];
|
out.y = _p[1];
|
||||||
|
|
||||||
cached_pos[? _cKey] = out.clone();
|
cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,12 +142,12 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
out.y = lerp(p0[1], p1[1], _rat);
|
out.y = lerp(p0[1], p1[1], _rat);
|
||||||
}
|
}
|
||||||
|
|
||||||
cached_pos[? _cKey] = out.clone();
|
cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static update = function() { #region
|
static update = function() {
|
||||||
ds_map_clear(cached_pos);
|
ds_map_clear(cached_pos);
|
||||||
|
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
|
@ -157,7 +158,7 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
|
|
||||||
#region bridge
|
#region bridge
|
||||||
var _lines = _path.getLineCount();
|
var _lines = _path.getLineCount();
|
||||||
var _p = new __vec2();
|
var _p = new __vec2P();
|
||||||
var _rat;
|
var _rat;
|
||||||
|
|
||||||
anchors = array_create(_amo);
|
anchors = array_create(_amo);
|
||||||
|
@ -259,5 +260,5 @@ function Node_Path_Bridge(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
} #endregion
|
}
|
||||||
}
|
}
|
|
@ -110,13 +110,14 @@ function Node_Path_Builder(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
||||||
static getAccuLength = function(ind = 0) { return lengthAccs[ind]; }
|
static getAccuLength = function(ind = 0) { return lengthAccs[ind]; }
|
||||||
|
|
||||||
static getPointDistance = function(_dist, ind = 0, out = undefined) {
|
static getPointDistance = function(_dist, ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _cKey = $"{ind}, {string_format(_dist, 0, 6)}";
|
var _cKey = $"{ind}, {string_format(_dist, 0, 6)}";
|
||||||
if(ds_map_exists(cached_pos, _cKey)) {
|
if(ds_map_exists(cached_pos, _cKey)) {
|
||||||
var _p = cached_pos[? _cKey];
|
var _p = cached_pos[? _cKey];
|
||||||
out.x = _p.x;
|
out.x = _p.x;
|
||||||
out.y = _p.y;
|
out.y = _p.y;
|
||||||
|
out.weight = _p.weight;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +149,7 @@ function Node_Path_Builder(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
||||||
out.y = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]);
|
out.y = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _a0[4], _a0[1] + _a0[5], _a1[0] + _a1[2], _a1[1] + _a1[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
cached_pos[? _cKey] = out.clone();
|
cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ function Node_Path_Fill(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
__tpath = _path;
|
__tpath = _path;
|
||||||
__step = 1 / _reso;
|
__step = 1 / _reso;
|
||||||
path_points = array_verify_ext(path_points, _reso, function() /*=>*/ {return new __vec2()});
|
path_points = array_verify_ext(path_points, _reso, function() /*=>*/ {return new __vec2P()});
|
||||||
|
|
||||||
surface_set_target(_outSurf);
|
surface_set_target(_outSurf);
|
||||||
if(_invt) { draw_clear(_colr); BLEND_SUBTRACT }
|
if(_invt) { draw_clear(_colr); BLEND_SUBTRACT }
|
||||||
|
|
|
@ -28,13 +28,14 @@ function Node_Path_From_Mask(_x, _y, _group = noone) : Node(_x, _y, _group) cons
|
||||||
static getLineCount = function() { return 1; }
|
static getLineCount = function() { return 1; }
|
||||||
|
|
||||||
static getPointDistance = function(_dist, _ind = 0, out = undefined) { #region
|
static getPointDistance = function(_dist, _ind = 0, out = undefined) { #region
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _cKey = $"{string_format(_dist, 0, 6)},{_ind}";
|
var _cKey = $"{string_format(_dist, 0, 6)},{_ind}";
|
||||||
if(ds_map_exists(cached_pos, _cKey)) {
|
if(ds_map_exists(cached_pos, _cKey)) {
|
||||||
var _p = cached_pos[? _cKey];
|
var _p = cached_pos[? _cKey];
|
||||||
out.x = _p.x;
|
out.x = _p.x;
|
||||||
out.y = _p.y;
|
out.y = _p.y;
|
||||||
|
out.weight = _p.weight;
|
||||||
|
|
||||||
// print($"Getting cache {_cKey} : {_dist} > {out}");
|
// print($"Getting cache {_cKey} : {_dist} > {out}");
|
||||||
return out;
|
return out;
|
||||||
|
@ -67,7 +68,7 @@ function Node_Path_From_Mask(_x, _y, _group = noone) : Node(_x, _y, _group) cons
|
||||||
|
|
||||||
// print($"Getting position {_cKey} : {_dist} - {i} > {out}");
|
// print($"Getting position {_cKey} : {_dist} - {i} > {out}");
|
||||||
|
|
||||||
cached_pos[? _cKey] = out.clone();
|
cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
|
@ -248,7 +248,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = path_3d? new __vec3() : new __vec2();
|
if(out == undefined) out = path_3d? new __vec3() : new __vec2P();
|
||||||
else { out.x = 0; out.y = 0; if(path_3d) out.z = 0; }
|
else { out.x = 0; out.y = 0; if(path_3d) out.z = 0; }
|
||||||
|
|
||||||
var _p0 = lines[_ind][0];
|
var _p0 = lines[_ind][0];
|
||||||
|
|
|
@ -50,7 +50,7 @@ function Node_Path_Map(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
|
||||||
|
|
||||||
var _pnt = array_create(_amo + 1);
|
var _pnt = array_create(_amo + 1);
|
||||||
var _isb = 1 / (_sub - 1);
|
var _isb = 1 / (_sub - 1);
|
||||||
var _pp = new __vec2();
|
var _pp = new __vec2P();
|
||||||
|
|
||||||
for( var i = 0; i < _amo; i++ ) {
|
for( var i = 0; i < _amo; i++ ) {
|
||||||
var _p = array_create(_sub + 1);
|
var _p = array_create(_sub + 1);
|
||||||
|
|
|
@ -37,7 +37,7 @@ function Node_Path_Map_Area(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
var _area = getInputData(1);
|
var _area = getInputData(1);
|
||||||
|
@ -55,6 +55,7 @@ function Node_Path_Map_Area(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
||||||
|
|
||||||
out.x = (_area[AREA_INDEX.center_x] - _area[AREA_INDEX.half_w]) + (_p.x - _b.minx) / _b.width * _area[AREA_INDEX.half_w] * 2;
|
out.x = (_area[AREA_INDEX.center_x] - _area[AREA_INDEX.half_w]) + (_p.x - _b.minx) / _b.width * _area[AREA_INDEX.half_w] * 2;
|
||||||
out.y = (_area[AREA_INDEX.center_y] - _area[AREA_INDEX.half_h]) + (_p.y - _b.miny) / _b.height * _area[AREA_INDEX.half_h] * 2;
|
out.y = (_area[AREA_INDEX.center_y] - _area[AREA_INDEX.half_h]) + (_p.y - _b.miny) / _b.height * _area[AREA_INDEX.half_h] * 2;
|
||||||
|
out.weight = _p.weight;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ function Node_Path_Morph(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
var _mid = _data[6];
|
var _mid = _data[6];
|
||||||
|
|
||||||
var _isb = 1 / (_sub - 1);
|
var _isb = 1 / (_sub - 1);
|
||||||
var _pp = new __vec2();
|
var _pp = new __vec2P();
|
||||||
|
|
||||||
if(_mid) {
|
if(_mid) {
|
||||||
var _p1 = array_create(_sub * 2);
|
var _p1 = array_create(_sub * 2);
|
||||||
|
|
|
@ -44,7 +44,7 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
||||||
static getAccuLength = function(ind = 0) { return [ length ]; }
|
static getAccuLength = function(ind = 0) { return [ length ]; }
|
||||||
|
|
||||||
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _sca = getInputData(0);
|
var _sca = getInputData(0);
|
||||||
var _coor = getInputData(1);
|
var _coor = getInputData(1);
|
||||||
|
@ -76,7 +76,7 @@ function Node_Path_Plot(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1 :
|
case 1 :
|
||||||
var _a = new __vec2();
|
var _a = new __vec2P();
|
||||||
switch(_eqa) {
|
switch(_eqa) {
|
||||||
case 0 :
|
case 0 :
|
||||||
_a.x = _rat * _iran[0] + _shf[0];
|
_a.x = _rat * _iran[0] + _shf[0];
|
||||||
|
|
|
@ -55,7 +55,7 @@ function Node_Path_Profile(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
if(_path == noone) return;
|
if(_path == noone) return;
|
||||||
|
|
||||||
var _points = array_create(_res * 2);
|
var _points = array_create(_res * 2);
|
||||||
var _p = new __vec2();
|
var _p = new __vec2P();
|
||||||
|
|
||||||
for( var i = 0; i < _res; i++ ) {
|
for( var i = 0; i < _res; i++ ) {
|
||||||
_p = _path.getPointRatio(i / _res, 0, _p);
|
_p = _path.getPointRatio(i / _res, 0, _p);
|
||||||
|
|
|
@ -56,7 +56,7 @@ function Node_Path_Repeat(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
static getAccuLength = function(i=0) /*=>*/ {return array_safe_get_fast(accu_lengths, i)};
|
static getAccuLength = function(i=0) /*=>*/ {return array_safe_get_fast(accu_lengths, i)};
|
||||||
|
|
||||||
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
||||||
out ??= new __vec2();
|
out ??= new __vec2P();
|
||||||
|
|
||||||
var _path = array_safe_get_fast(paths, ind, 0);
|
var _path = array_safe_get_fast(paths, ind, 0);
|
||||||
if(_path == 0) return out;
|
if(_path == 0) return out;
|
||||||
|
|
|
@ -9,54 +9,54 @@ function Node_Path_Reverse(_x, _y, _group = noone) : Node(_x, _y, _group) constr
|
||||||
|
|
||||||
cached_pos = ds_map_create();
|
cached_pos = ds_map_create();
|
||||||
|
|
||||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getLineCount = function() { #region
|
static getLineCount = function() {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
return struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
return struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getSegmentCount = function(ind = 0) { #region
|
static getSegmentCount = function(ind = 0) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 0;
|
return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 0;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getLength = function(ind = 0) { #region
|
static getLength = function(ind = 0) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
return struct_has(_path, "getLength")? _path.getLength(ind) : 0;
|
return struct_has(_path, "getLength")? _path.getLength(ind) : 0;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getAccuLength = function(ind = 0) { #region
|
static getAccuLength = function(ind = 0) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
return struct_has(_path, "getAccuLength")? array_reverse(_path.getAccuLength(ind)) : [];
|
return struct_has(_path, "getAccuLength")? array_reverse(_path.getAccuLength(ind)) : [];
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getBoundary = function(ind = 0) { #region
|
static getBoundary = function(ind = 0) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox(0, 0, 1, 1);
|
return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox(0, 0, 1, 1);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getPointRatio = function(_rat, ind = 0, out = undefined) { #region
|
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
|
|
||||||
if(!is_struct(_path) || !struct_has(_path, "getPointRatio"))
|
if(!is_struct(_path) || !struct_has(_path, "getPointRatio"))
|
||||||
return out;
|
return out;
|
||||||
return _path.getPointRatio(1 - _rat, ind, out);
|
return _path.getPointRatio(1 - _rat, ind, out);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); }
|
static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); }
|
||||||
|
|
||||||
static update = function() { #region
|
static update = function() {
|
||||||
ds_map_clear(cached_pos);
|
ds_map_clear(cached_pos);
|
||||||
outputs[0].setValue(self);
|
outputs[0].setValue(self);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||||
var bbox = drawGetBbox(xx, yy, _s);
|
var bbox = drawGetBbox(xx, yy, _s);
|
||||||
draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
||||||
} #endregion
|
}
|
||||||
}
|
}
|
|
@ -67,7 +67,7 @@ function Node_Path_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
static getAccuLength = function(i=0) /*=>*/ {return array_safe_get_fast(accu_lengths, i)};
|
static getAccuLength = function(i=0) /*=>*/ {return array_safe_get_fast(accu_lengths, i)};
|
||||||
|
|
||||||
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _path = array_safe_get_fast(paths, ind, 0);
|
var _path = array_safe_get_fast(paths, ind, 0);
|
||||||
if(_path == 0) return out;
|
if(_path == 0) return out;
|
||||||
|
@ -140,7 +140,7 @@ function Node_Path_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
|
|
||||||
random_set_seed(_seed);
|
random_set_seed(_seed);
|
||||||
var _ind = 0;
|
var _ind = 0;
|
||||||
var p = new __vec2();
|
var p = new __vec2P();
|
||||||
var ori, pos;
|
var ori, pos;
|
||||||
var _prog_raw, _prog;
|
var _prog_raw, _prog;
|
||||||
var _dir, _sca, _rot, _rotW, _trm;
|
var _dir, _sca, _rot, _rotW, _trm;
|
||||||
|
|
|
@ -43,7 +43,7 @@ function Node_Path_SDF(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
var _p = array_create((_sub + 1) * 2);
|
var _p = array_create((_sub + 1) * 2);
|
||||||
var _isb = 1 / _sub;
|
var _isb = 1 / _sub;
|
||||||
var _pp = new __vec2();
|
var _pp = new __vec2P();
|
||||||
|
|
||||||
for( var i = 0; i <= _sub; i++ ) {
|
for( var i = 0; i <= _sub; i++ ) {
|
||||||
var _prog = frac(i * _isb);
|
var _prog = frac(i * _isb);
|
||||||
|
|
|
@ -75,7 +75,7 @@ function Node_Path_Shape(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
static getAccuLength = function() /*=>*/ {return lengthAccs};
|
static getAccuLength = function() /*=>*/ {return lengthAccs};
|
||||||
|
|
||||||
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
||||||
out ??= new __vec2();
|
out ??= new __vec2P();
|
||||||
_rat = frac(_rat);
|
_rat = frac(_rat);
|
||||||
|
|
||||||
switch(shapeScroll[shape].name) {
|
switch(shapeScroll[shape].name) {
|
||||||
|
@ -115,7 +115,7 @@ function Node_Path_Shape(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPointDistance = function(_dist, _ind = 0, out = undefined) {
|
static getPointDistance = function(_dist, _ind = 0, out = undefined) {
|
||||||
out ??= new __vec2();
|
out ??= new __vec2P();
|
||||||
_dist = safe_mod(_dist, lengthTotal);
|
_dist = safe_mod(_dist, lengthTotal);
|
||||||
|
|
||||||
var _d = _dist, l;
|
var _d = _dist, l;
|
||||||
|
|
|
@ -22,7 +22,7 @@ function Node_Path_Shift(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
var _len = getLength(_amo);
|
var _len = getLength(_amo);
|
||||||
var _stp = 1 / clamp(_len * _s, 1, 64);
|
var _stp = 1 / clamp(_len * _s, 1, 64);
|
||||||
var ox, oy, nx, ny;
|
var ox, oy, nx, ny;
|
||||||
var _p = new __vec2();
|
var _p = new __vec2P();
|
||||||
|
|
||||||
for( var j = 0; j < 1; j += _stp ) {
|
for( var j = 0; j < 1; j += _stp ) {
|
||||||
_p = getPointRatio(j, i, _p);
|
_p = getPointRatio(j, i, _p);
|
||||||
|
@ -58,13 +58,14 @@ function Node_Path_Shift(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
|
var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
|
||||||
if(ds_map_exists(cached_pos, _cKey)) {
|
if(ds_map_exists(cached_pos, _cKey)) {
|
||||||
var _p = cached_pos[? _cKey];
|
var _p = cached_pos[? _cKey];
|
||||||
out.x = _p.x;
|
out.x = _p.x;
|
||||||
out.y = _p.y;
|
out.y = _p.y;
|
||||||
|
out.weight = _p.weight;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +88,9 @@ function Node_Path_Shift(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||||
|
|
||||||
out.x += _p.x + lengthdir_x(_shf, dir);
|
out.x += _p.x + lengthdir_x(_shf, dir);
|
||||||
out.y += _p.y + lengthdir_y(_shf, dir);
|
out.y += _p.y + lengthdir_y(_shf, dir);
|
||||||
|
out.weight = _p.weight;
|
||||||
|
|
||||||
cached_pos[? _cKey] = out.clone();
|
cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
line_hover = _line_hover;
|
line_hover = _line_hover;
|
||||||
|
|
||||||
if(key_mod_press(CTRL) || isUsingTool(0)) { // anchor edit
|
if(key_mod_press(CTRL) || isUsingTool(0)) { // anchor edit
|
||||||
draw_sprite_ui_uniform(_anchor_hover == -1? THEME.cursor_path_add : THEME.cursor_path_remove, 0, _mx + 16, _my + 16);
|
draw_sprite_ui_uniform(_anchor_hover == -1? THEME.cursor_path_add : THEME.cursor_path_remove, 0, _mx + 4, _my + 4);
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
if(mouse_press(mb_left, active)) {
|
||||||
if(_anchor_hover == -1) {
|
if(_anchor_hover == -1) {
|
||||||
|
@ -238,7 +238,7 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
static getAccuLength = function() { return lengthAccs; }
|
static getAccuLength = function() { return lengthAccs; }
|
||||||
|
|
||||||
static getPointDistance = function(_dist, _ind = 0, out = undefined) {
|
static getPointDistance = function(_dist, _ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
if(array_empty(lengths)) return out;
|
if(array_empty(lengths)) return out;
|
||||||
|
|
||||||
var _cKey = _dist;
|
var _cKey = _dist;
|
||||||
|
@ -246,6 +246,7 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
var _p = cached_pos[? _cKey];
|
var _p = cached_pos[? _cKey];
|
||||||
out.x = _p.x;
|
out.x = _p.x;
|
||||||
out.y = _p.y;
|
out.y = _p.y;
|
||||||
|
out.weight = _p.weight;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +277,7 @@ function Node_Path_Smooth(_x, _y, _group = noone) : Node(_x, _y, _group) constru
|
||||||
out.y = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _c0[2], _a0[1] + _c0[3], _a1[0] + _c1[0], _a1[1] + _c1[1]);
|
out.y = eval_bezier_y(_t, _a0[0], _a0[1], _a1[0], _a1[1], _a0[0] + _c0[2], _a0[1] + _c0[3], _a1[0] + _c1[0], _a1[1] + _c1[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
cached_pos[? _cKey] = out.clone();
|
cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ function Node_Path_Transform(_x, _y, _group = noone) : Node(_x, _y, _group) cons
|
||||||
rot = 0;
|
rot = 0;
|
||||||
sca = [ 1, 1 ];
|
sca = [ 1, 1 ];
|
||||||
anc = [ 0, 0 ];
|
anc = [ 0, 0 ];
|
||||||
p = new __vec2();
|
p = new __vec2P();
|
||||||
|
|
||||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
|
@ -91,13 +91,14 @@ function Node_Path_Transform(_x, _y, _group = noone) : Node(_x, _y, _group) cons
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
||||||
out ??= new __vec2();
|
out ??= new __vec2P();
|
||||||
|
|
||||||
var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
|
var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
|
||||||
if(ds_map_exists(cached_pos, _cKey)) {
|
if(ds_map_exists(cached_pos, _cKey)) {
|
||||||
var _p = cached_pos[? _cKey];
|
var _p = cached_pos[? _cKey];
|
||||||
out.x = _p.x;
|
out.x = _p.x;
|
||||||
out.y = _p.y;
|
out.y = _p.y;
|
||||||
|
out.weight = _p.weight;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,8 +119,9 @@ function Node_Path_Transform(_x, _y, _group = noone) : Node(_x, _y, _group) cons
|
||||||
|
|
||||||
out.x = _pp[0] + pos[0];
|
out.x = _pp[0] + pos[0];
|
||||||
out.y = _pp[1] + pos[1];
|
out.y = _pp[1] + pos[1];
|
||||||
|
out.weight = _p.weight;
|
||||||
|
|
||||||
cached_pos[? _cKey] = out.clone();
|
cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
||||||
|
|
||||||
cached_pos = ds_map_create();
|
cached_pos = ds_map_create();
|
||||||
|
|
||||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
||||||
var _len = getLength(_amo);
|
var _len = getLength(_amo);
|
||||||
var _stp = 1 / clamp(_len * _s, 1, 64);
|
var _stp = 1 / clamp(_len * _s, 1, 64);
|
||||||
var ox, oy, nx, ny;
|
var ox, oy, nx, ny;
|
||||||
var _p = new __vec2();
|
var _p = new __vec2P();
|
||||||
|
|
||||||
for( var j = 0; j < 1; j += _stp ) {
|
for( var j = 0; j < 1; j += _stp ) {
|
||||||
_p = getPointRatio(j, i, _p);
|
_p = getPointRatio(j, i, _p);
|
||||||
|
@ -35,30 +35,30 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
||||||
oy = ny;
|
oy = ny;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getLineCount = function() { #region
|
static getLineCount = function() {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
return struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
return struct_has(_path, "getLineCount")? _path.getLineCount() : 1;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getSegmentCount = function(ind = 0) { #region
|
static getSegmentCount = function(ind = 0) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 0;
|
return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 0;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getLength = function(ind = 0) { #region
|
static getLength = function(ind = 0) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
return struct_has(_path, "getLength")? _path.getLength(ind) : 0;
|
return struct_has(_path, "getLength")? _path.getLength(ind) : 0;
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getAccuLength = function(ind = 0) { #region
|
static getAccuLength = function(ind = 0) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
return struct_has(_path, "getAccuLength")? _path.getAccuLength(ind) : [];
|
return struct_has(_path, "getAccuLength")? _path.getAccuLength(ind) : [];
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getPointRatio = function(_rat, ind = 0, out = undefined) { #region
|
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
var _rng = getInputData(1);
|
var _rng = getInputData(1);
|
||||||
|
@ -74,22 +74,22 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
||||||
_rat = _rng[0] + _rat * (_rng[1] - _rng[0]);
|
_rat = _rng[0] + _rat * (_rng[1] - _rng[0]);
|
||||||
|
|
||||||
return _path.getPointRatio(_rat, ind, out);
|
return _path.getPointRatio(_rat, ind, out);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); }
|
static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); }
|
||||||
|
|
||||||
static getBoundary = function(ind = 0) { #region
|
static getBoundary = function(ind = 0) {
|
||||||
var _path = getInputData(0);
|
var _path = getInputData(0);
|
||||||
return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox( 0, 0, 1, 1 );
|
return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox( 0, 0, 1, 1 );
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static update = function() { #region
|
static update = function() {
|
||||||
ds_map_clear(cached_pos);
|
ds_map_clear(cached_pos);
|
||||||
outputs[0].setValue(self);
|
outputs[0].setValue(self);
|
||||||
} #endregion
|
}
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||||
var bbox = drawGetBbox(xx, yy, _s);
|
var bbox = drawGetBbox(xx, yy, _s);
|
||||||
draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
||||||
} #endregion
|
}
|
||||||
}
|
}
|
|
@ -47,9 +47,9 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
||||||
|
|
||||||
wig_map = noone;
|
wig_map = noone;
|
||||||
amp_curve = noone;
|
amp_curve = noone;
|
||||||
p = new __vec2();
|
p = new __vec2P();
|
||||||
p0 = new __vec2();
|
p0 = new __vec2P();
|
||||||
p1 = new __vec2();
|
p1 = new __vec2P();
|
||||||
|
|
||||||
cached_pos = ds_map_create();
|
cached_pos = ds_map_create();
|
||||||
|
|
||||||
|
@ -112,13 +112,14 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
static getPointRatio = function(_rat, ind = 0, out = undefined) {
|
||||||
if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; }
|
if(out == undefined) out = new __vec2P(); else { out.x = 0; out.y = 0; }
|
||||||
|
|
||||||
var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
|
var _cKey = $"{string_format(_rat, 0, 6)},{ind}";
|
||||||
if(ds_map_exists(cached_pos, _cKey)) {
|
if(ds_map_exists(cached_pos, _cKey)) {
|
||||||
var _p = cached_pos[? _cKey];
|
var _p = cached_pos[? _cKey];
|
||||||
out.x = _p.x;
|
out.x = _p.x;
|
||||||
out.y = _p.y;
|
out.y = _p.y;
|
||||||
|
out.weight = _p.weight;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +176,9 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
||||||
|
|
||||||
out.x = p.x + lengthdir_x(_amp * prg, dir);
|
out.x = p.x + lengthdir_x(_amp * prg, dir);
|
||||||
out.y = p.y + lengthdir_y(_amp * prg, dir);
|
out.y = p.y + lengthdir_y(_amp * prg, dir);
|
||||||
|
out.weight = p.weight;
|
||||||
|
|
||||||
cached_pos[? _cKey] = out.clone();
|
cached_pos[? _cKey] = new __vec2P(out.x, out.y, out.weight);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,8 +361,8 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
|
|
||||||
__temp_tx = tx + _pthS;
|
__temp_tx = tx + _pthS;
|
||||||
__temp_ty = ty;
|
__temp_ty = ty;
|
||||||
__temp_p0 = new __vec2();
|
__temp_p0 = new __vec2P();
|
||||||
__temp_p1 = new __vec2();
|
__temp_p1 = new __vec2P();
|
||||||
|
|
||||||
string_foreach(_str_line, function(_chr, _ind) {
|
string_foreach(_str_line, function(_chr, _ind) {
|
||||||
var _p1 = __temp_pt.getPointDistance(__temp_tx, 0, __temp_p0);
|
var _p1 = __temp_pt.getPointDistance(__temp_tx, 0, __temp_p0);
|
||||||
|
|
Loading…
Reference in a new issue