From 2132e339572a408e7b782eb4f6cb573041403fac Mon Sep 17 00:00:00 2001 From: Tanasart Date: Mon, 22 Jan 2024 20:23:35 +0700 Subject: [PATCH] Path improvement --- fonts/_f_sdf/_f_sdf.old.png | Bin 82361 -> 82361 bytes fonts/_f_sdf/_f_sdf.png | Bin 82361 -> 82361 bytes fonts/_f_sdf_medium/_f_sdf_medium.old.png | Bin 59906 -> 59906 bytes fonts/_f_sdf_medium/_f_sdf_medium.png | Bin 59906 -> 59906 bytes scripts/node_array_range/node_array_range.gml | 34 ++- scripts/node_path/node_path.gml | 18 +- scripts/node_path_anchor/node_path_anchor.gml | 2 +- scripts/node_path_array/node_path_array.gml | 4 - scripts/node_path_blend/node_path_blend.gml | 66 ++++-- .../node_path_builder/node_path_builder.gml | 4 +- .../node_path_reverse/node_path_reverse.gml | 42 ++-- scripts/node_path_sample/node_path_sample.gml | 30 ++- scripts/node_path_shift/node_path_shift.gml | 58 +++-- scripts/node_path_trim/node_path_trim.gml | 61 ++++-- scripts/node_path_wave/node_path_wave.gml | 199 +++++++++++++----- .../node_simple_shape/node_simple_shape.gml | 9 +- scripts/panel_inspector/panel_inspector.gml | 15 +- scripts/random_function/random_function.gml | 11 +- shaders/sh_shape/sh_shape.fsh | 5 +- 19 files changed, 376 insertions(+), 182 deletions(-) diff --git a/fonts/_f_sdf/_f_sdf.old.png b/fonts/_f_sdf/_f_sdf.old.png index d1404809a05c857bc1dd2cb2c0e328ac399e117a..84a5a9db517f712882ca6d5779bd82ebec64ac5a 100644 GIT binary patch delta 87 zcmdnl%(}CgwP6dRxuc+om5Gs+v4ysQft7)Q>^6tR(>)v+6;Oq9UjLAvUg^lFEQ_Mr T`rpk13_#%N>gTe~DWM4fK?NA+ delta 87 zcmdnl%(}CgwP6dRxuc+wm8q$fiHWv>ft7(laEisM=^l=Z3aG+LmJMRlD;*h?Wl>a@ S>MT6T00f?{elF{r5}E+^A{K)H diff --git a/fonts/_f_sdf/_f_sdf.png b/fonts/_f_sdf/_f_sdf.png index 84a5a9db517f712882ca6d5779bd82ebec64ac5a..67979db52c7fe7ce719ac9cc2fac705998a1b109 100644 GIT binary patch delta 90 zcmdnl%(}CgwP6dRnWK=Qp_P%Tm8prgfq|8Q!8C&f{L?)g8RgN$pXW+!o?hw5s3eD~ UenW+24g(N)y85}Sb4q9e08}j(*#H0l delta 90 zcmdnl%(}CgwP6dRnWK<_iIs_wm9d4kfq|8Qf$TPi#nU|;8RgN$b6)?DpI+(6s3eD~ U-umCo0}Mdm>FVdQ&MBb@0DcY`cK`qY diff --git a/fonts/_f_sdf_medium/_f_sdf_medium.old.png b/fonts/_f_sdf_medium/_f_sdf_medium.old.png index 1df097eef61ace44d59235ac55d1f1b956e3bb5b..260587b930861321793e223ce23a9526312a3ed8 100644 GIT binary patch delta 83 zcmZp=!rXL)c|*fXK@%$zBP(MIZ36=<0|VJ@4vQyGe5rscn)CXH{NzI~m1R-XTK~Iw QfB^_RUHx3vIVCg!0G+KHTL1t6 delta 83 zcmZp=!rXL)c|*fXK_e?uQ!5h_Z36=<1B2ici&c{+zEnUJRkCaln|$b{vMh?)Qk{h- P8Gyjk)z4*}Q$iB}RFfF@ diff --git a/fonts/_f_sdf_medium/_f_sdf_medium.png b/fonts/_f_sdf_medium/_f_sdf_medium.png index 260587b930861321793e223ce23a9526312a3ed8..1122794b5c490f284f027a65bfd76fa53d0443e3 100644 GIT binary patch delta 86 zcmZp=!rXL)c|-k6AwxqeBU39=6Kw+nD+7aR1`GHnPkbqlCj2~CV)NufFO}p_Rd1-U Q%wYfmPgg&ebxsLQ0JXOoO#lD@ delta 86 zcmZp=!rXL)c|-k6Ap;XD6C*2Q3vB}fD+2@BZ4QekPkbqlCY 0 && st <= ed) || (step < 0 && st >= ed)) { - for( var i = st; i <= ed; i += step ) - array_push(arr, i); + if(st == ed) { + arr = array_create(stp, st); + } else if(sign(stp) == sign(ed - st)) { + var _amo = floor(abs((ed - st) / stp)); + + for( var i = 0; i < _amo; i++ ) + array_push(arr, st + i * stp); } outputs[| 0].setValue(arr); @@ -33,11 +36,20 @@ function Node_Array_Range(_x, _y, _group = noone) : Node(_x, _y, _group) constru var str = getInputData(0); var edd = getInputData(1); var stp = getInputData(2); + var arr = outputs[| 0].getValue(); - var str = "[" + string(str) + ", " + string(str + stp) + ", ... ," + string(edd) + "]"; + var str = ""; + switch(array_length(arr)) { + case 0 : str = $"[]" break; + case 1 : + case 2 : + case 3 : str = $"{arr}" break; + + default : str = $"[{arr[0]}, {arr[1]}, ..., {array_safe_get(arr, -1,, ARRAY_OVERFLOW.loop)}]"; break; + } var bbox = drawGetBbox(xx, yy, _s); - var ss = string_scale(str, bbox.w, bbox.h); + var ss = string_scale(str, bbox.w, bbox.h); draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0); } } \ No newline at end of file diff --git a/scripts/node_path/node_path.gml b/scripts/node_path/node_path.gml index 891dbfaf4..e6e4070c7 100644 --- a/scripts/node_path/node_path.gml +++ b/scripts/node_path/node_path.gml @@ -27,13 +27,6 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { inputs[| 3] = nodeValue("Round anchor", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false) .rejectArray(); - input_display_list = [ - ["Path", false], 0, 2, 1, 3, - ["Anchors", false], - ]; - - setIsDynamicInput(1); - outputs[| 0] = nodeValue("Position out", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [ 0, 0 ]) .setDisplay(VALUE_DISPLAY.vector); @@ -43,6 +36,13 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { .setVisible(false) .setArrayDepth(1); + input_display_list = [ + ["Path", false], 0, 2, 1, 3, + ["Anchors", false], + ]; + + setIsDynamicInput(1); + 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("Replace", VALUE_TYPE.boolean, function() { tool_pathDrawer.attribute.create = !tool_pathDrawer.attribute.create; }, "create", true); @@ -635,7 +635,9 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { } draw_sprite_colored(THEME.anchor_selector, 0, xx, yy); - + draw_set_text(f_p1, fa_left, fa_bottom, COLORS._main_accent); + draw_text(xx + ui(4), yy - ui(4), i + 1); + if(drag_point == i) { draw_sprite_colored(THEME.anchor_selector, 1, xx, yy); } else if(point_in_circle(_mx, _my, xx, yy, 8)) { diff --git a/scripts/node_path_anchor/node_path_anchor.gml b/scripts/node_path_anchor/node_path_anchor.gml index cb8308698..febfcd6bb 100644 --- a/scripts/node_path_anchor/node_path_anchor.gml +++ b/scripts/node_path_anchor/node_path_anchor.gml @@ -13,7 +13,7 @@ function Node_Path_Anchor(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou inputs[| 2] = nodeValue("Control point 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 16, 0 ] ) .setDisplay(VALUE_DISPLAY.vector); - inputs[| 3] = nodeValue("Mirror control point", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false ); + inputs[| 3] = nodeValue("Mirror control point", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true ); outputs[| 0] = nodeValue("Anchor", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [ 0, 0, 0, 0, 0, 0 ]) .setDisplay(VALUE_DISPLAY.vector); diff --git a/scripts/node_path_array/node_path_array.gml b/scripts/node_path_array/node_path_array.gml index 564be6c9b..d0db54b40 100644 --- a/scripts/node_path_array/node_path_array.gml +++ b/scripts/node_path_array/node_path_array.gml @@ -137,8 +137,4 @@ function Node_Path_Array(_x, _y, _group = noone) : Node(_x, _y, _group) construc static update = function(frame = CURRENT_FRAME) { #region outputs[| 0].setValue(self); } #endregion - - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region - - } #endregion } \ No newline at end of file diff --git a/scripts/node_path_blend/node_path_blend.gml b/scripts/node_path_blend/node_path_blend.gml index e743abaf4..75af0b0ad 100644 --- a/scripts/node_path_blend/node_path_blend.gml +++ b/scripts/node_path_blend/node_path_blend.gml @@ -1,7 +1,6 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { - name = "Blend Path"; - - w = 96; + name = "Blend Path"; + w = 96; length = 0; inputs[| 0] = nodeValue("Path 1", self, JUNCTION_CONNECT.input, VALUE_TYPE.pathnode, noone) @@ -18,12 +17,41 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc outputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.output, VALUE_TYPE.pathnode, self); - static getLineCount = function() { + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + var _p0 = getInputData(0); + var _p1 = getInputData(1); + + if(_p0) _p0.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + if(_p1) _p1.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + + draw_set_color(COLORS._main_icon); + + var _amo = getLineCount(); + for( var i = 0; i < _amo; i++ ) { + var _len = getLength(_amo); + var _stp = 1 / clamp(_len * _s, 1, 64); + var ox, oy, nx, ny; + var _p = new __vec2(); + + for( var j = 0; j < 1; j += _stp ) { + _p = getPointRatio(j, i, _p); + nx = _x + _p.x * _s; + ny = _y + _p.y * _s; + + if(j > 0) draw_line_width(ox, oy, nx, ny, 3); + + ox = nx; + oy = ny; + } + } + } #endregion + + static getLineCount = function() { #region var _path = getInputData(0); return struct_has(_path, "getLineCount")? _path.getLineCount() : 1; - } + } #endregion - static getSegmentCount = function(ind = 0) { + static getSegmentCount = function(ind = 0) { #region var _path1 = getInputData(0); var _path2 = getInputData(1); var _lerp = getInputData(2); @@ -36,9 +64,9 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc if(!p1 && p2) return _path2.getSegmentCount(ind); return max(_path1.getSegmentCount(ind), _path2.getSegmentCount(ind)); - } + } #endregion - static getLength = function(ind = 0) { + static getLength = function(ind = 0) { #region var _path1 = getInputData(0); var _path2 = getInputData(1); var _lerp = getInputData(2); @@ -54,9 +82,9 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc var _p2 = _path2.getLength(ind); return lerp(_p1, _p2, _lerp); - } + } #endregion - static getAccuLength = function(ind = 0) { + static getAccuLength = function(ind = 0) { #region var _path1 = getInputData(0); var _path2 = getInputData(1); var _lerp = getInputData(2); @@ -82,9 +110,9 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc } return res; - } + } #endregion - static getPointRatio = function(_rat, ind = 0, out = undefined) { + static getPointRatio = function(_rat, ind = 0, out = undefined) { #region if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } var _path1 = getInputData(0); @@ -105,11 +133,11 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc out.y = lerp(_p1.y, _p2.y, _lerp); return out; - } + } #endregion static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(ind), ind, out); } - static getBoundary = function(ind = 0) { + static getBoundary = function(ind = 0) { #region var _path1 = getInputData(0); var _path2 = getInputData(1); var _lerp = getInputData(2); @@ -125,14 +153,14 @@ function Node_Path_Blend(_x, _y, _group = noone) : Node(_x, _y, _group) construc var _p2 = _path2.getBoundary(ind); return _p1.lerpTo(_p2, _lerp); - } + } #endregion - static update = function() { + static update = function() { #region outputs[| 0].setValue(self); - } + } #endregion - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region var bbox = drawGetBbox(xx, yy, _s); draw_sprite_fit(s_node_path_blend, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_path_builder/node_path_builder.gml b/scripts/node_path_builder/node_path_builder.gml index aca5b01e1..20d359c23 100644 --- a/scripts/node_path_builder/node_path_builder.gml +++ b/scripts/node_path_builder/node_path_builder.gml @@ -1,7 +1,7 @@ function Node_Path_Builder(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { - name = "Path Builder"; + name = "Path Builder"; + w = 96; - w = 96; length = []; lengthAcc = []; diff --git a/scripts/node_path_reverse/node_path_reverse.gml b/scripts/node_path_reverse/node_path_reverse.gml index 78a1145c2..674d84c5c 100644 --- a/scripts/node_path_reverse/node_path_reverse.gml +++ b/scripts/node_path_reverse/node_path_reverse.gml @@ -1,55 +1,59 @@ function Node_Path_Reverse(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { - name = "Reverse Path"; - - w = 96; + name = "Reverse Path"; + w = 96; inputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.input, VALUE_TYPE.pathnode, noone) .setVisible(true, true); outputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.output, VALUE_TYPE.pathnode, self); - static getLineCount = function() { + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + var _path = getInputData(0); + if(_path) _path.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + } #endregion + + static getLineCount = function() { #region var _path = getInputData(0); return struct_has(_path, "getLineCount")? _path.getLineCount() : 1; - } + } #endregion - static getSegmentCount = function(ind = 0) { + static getSegmentCount = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 0; - } + } #endregion - static getLength = function(ind = 0) { + static getLength = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getLength")? _path.getLength(ind) : 0; - } + } #endregion - static getAccuLength = function(ind = 0) { + static getAccuLength = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getAccuLength")? array_reverse(_path.getAccuLength(ind)) : []; - } + } #endregion - static getBoundary = function(ind = 0) { + static getBoundary = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox(0, 0, 1, 1); - } + } #endregion - static getPointRatio = function(_rat, ind = 0, out = undefined) { + static getPointRatio = function(_rat, ind = 0, out = undefined) { #region if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } var _path = getInputData(0); if(!is_struct(_path) || !struct_has(_path, "getPointRatio")) return out; return _path.getPointRatio(1 - _rat, ind, out); - } + } #endregion static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); } - static update = function() { + static update = function() { #region outputs[| 0].setValue(self); - } + } #endregion - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region var bbox = drawGetBbox(xx, yy, _s); draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_path_sample/node_path_sample.gml b/scripts/node_path_sample/node_path_sample.gml index 73185c1c6..76515de41 100644 --- a/scripts/node_path_sample/node_path_sample.gml +++ b/scripts/node_path_sample/node_path_sample.gml @@ -1,7 +1,6 @@ function Node_Path_Sample(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { - name = "Sample Path"; - - w = 96; + name = "Sample Path"; + w = 96; inputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.input, VALUE_TYPE.pathnode, noone) .setVisible(true, true); @@ -16,7 +15,24 @@ function Node_Path_Sample(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou outputs[| 1] = nodeValue("Direction", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0); - static processData = function(_output, _data, _output_index, _array_index = 0) { + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + var _path = getInputData(0); + if(_path) _path.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + + var _pnt = outputs[| 0].getValue(); + if(process_amount == 1) _pnt = [ _pnt ]; + + draw_set_color(COLORS._main_accent); + for( var i = 0, n = array_length(_pnt); i < n; i++ ) { + var _p = _pnt[i]; + var _px = _x + _p[0] * _s; + var _py = _y + _p[1] * _s; + + draw_circle(_px, _py, 4, false); + } + } #endregion + + static processData = function(_output, _data, _output_index, _array_index = 0) { #region var _path = _data[0]; var _rat = _data[1]; var _mod = _data[2]; @@ -54,10 +70,10 @@ function Node_Path_Sample(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou var dir = inv? p1.directionTo(p0) : p0.directionTo(p1); return dir; } - } + } #endregion - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region var bbox = drawGetBbox(xx, yy, _s); draw_sprite_fit(THEME.node_draw_path, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_path_shift/node_path_shift.gml b/scripts/node_path_shift/node_path_shift.gml index d24c4a072..56168fcc3 100644 --- a/scripts/node_path_shift/node_path_shift.gml +++ b/scripts/node_path_shift/node_path_shift.gml @@ -10,27 +10,53 @@ function Node_Path_Shift(_x, _y, _group = noone) : Node(_x, _y, _group) construc outputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.output, VALUE_TYPE.pathnode, self); - static getLineCount = function() { + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + var _path = getInputData(0); + if(_path) _path.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + + draw_set_color(COLORS._main_icon); + + var _amo = getLineCount(); + for( var i = 0; i < _amo; i++ ) { + var _len = getLength(_amo); + var _stp = 1 / clamp(_len * _s, 1, 64); + var ox, oy, nx, ny; + var _p = new __vec2(); + + for( var j = 0; j < 1; j += _stp ) { + _p = getPointRatio(j, i, _p); + nx = _x + _p.x * _s; + ny = _y + _p.y * _s; + + if(j > 0) draw_line_width(ox, oy, nx, ny, 3); + + ox = nx; + oy = ny; + } + } + } #endregion + + static getLineCount = function() { #region var _path = getInputData(0); return struct_has(_path, "getLineCount")? _path.getLineCount() : 1; - } + } #endregion - static getSegmentCount = function(ind = 0) { + static getSegmentCount = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 0; - } + } #endregion - static getLength = function(ind = 0) { + static getLength = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getLength")? _path.getLength(ind) : 0; - } + } #endregion - static getAccuLength = function(ind = 0) { + static getAccuLength = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getAccuLength")? _path.getAccuLength(ind) : []; - } + } #endregion - static getPointRatio = function(_rat, ind = 0, out = undefined) { + static getPointRatio = function(_rat, ind = 0, out = undefined) { #region if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } var _path = getInputData(0); @@ -54,21 +80,21 @@ function Node_Path_Shift(_x, _y, _group = noone) : Node(_x, _y, _group) construc out.y += _p.y + lengthdir_y(_shf, dir); return out; - } + } #endregion static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); } - static getBoundary = function(ind = 0) { + static getBoundary = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox( 0, 0, 1, 1 ); - } + } #endregion - static update = function() { + static update = function() { #region outputs[| 0].setValue(self); - } + } #endregion - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region var bbox = drawGetBbox(xx, yy, _s); draw_sprite_fit(s_node_path_shift, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_path_trim/node_path_trim.gml b/scripts/node_path_trim/node_path_trim.gml index 0e3293fbf..7394e61f7 100644 --- a/scripts/node_path_trim/node_path_trim.gml +++ b/scripts/node_path_trim/node_path_trim.gml @@ -1,7 +1,6 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { - name = "Trim Path"; - - w = 96; + name = "Trim Path"; + w = 96; inputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.input, VALUE_TYPE.pathnode, noone) .setVisible(true, true); @@ -11,27 +10,53 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct outputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.output, VALUE_TYPE.pathnode, self); - static getLineCount = function() { + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + var _path = getInputData(0); + if(_path) _path.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + + draw_set_color(COLORS._main_icon); + + var _amo = getLineCount(); + for( var i = 0; i < _amo; i++ ) { + var _len = getLength(_amo); + var _stp = 1 / clamp(_len * _s, 1, 64); + var ox, oy, nx, ny; + var _p = new __vec2(); + + for( var j = 0; j < 1; j += _stp ) { + _p = getPointRatio(j, i, _p); + nx = _x + _p.x * _s; + ny = _y + _p.y * _s; + + if(j > 0) draw_line_width(ox, oy, nx, ny, 3); + + ox = nx; + oy = ny; + } + } + } #endregion + + static getLineCount = function() { #region var _path = getInputData(0); return struct_has(_path, "getLineCount")? _path.getLineCount() : 1; - } + } #endregion - static getSegmentCount = function(ind = 0) { + static getSegmentCount = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 0; - } + } #endregion - static getLength = function(ind = 0) { + static getLength = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getLength")? _path.getLength(ind) : 0; - } + } #endregion - static getAccuLength = function(ind = 0) { + static getAccuLength = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getAccuLength")? _path.getAccuLength(ind) : []; - } + } #endregion - static getPointRatio = function(_rat, ind = 0, out = undefined) { + static getPointRatio = function(_rat, ind = 0, out = undefined) { #region if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } var _path = getInputData(0); @@ -47,21 +72,21 @@ function Node_Path_Trim(_x, _y, _group = noone) : Node(_x, _y, _group) construct _rat = _rng[0] + _rat * (_rng[1] - _rng[0]); return _path.getPointRatio(_rat, ind, out); - } + } #endregion static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); } - static getBoundary = function(ind = 0) { + static getBoundary = function(ind = 0) { #region var _path = getInputData(0); return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox( 0, 0, 1, 1 ); - } + } #endregion - static update = function() { + static update = function() { #region outputs[| 0].setValue(self); - } + } #endregion static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { var bbox = drawGetBbox(xx, yy, _s); draw_sprite_fit(s_node_path_trim, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_path_wave/node_path_wave.gml b/scripts/node_path_wave/node_path_wave.gml index 55fe96de2..b11bf3090 100644 --- a/scripts/node_path_wave/node_path_wave.gml +++ b/scripts/node_path_wave/node_path_wave.gml @@ -1,69 +1,142 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { - name = "Wave Path"; - - w = 96; + name = "Wave Path"; + w = 96; inputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.input, VALUE_TYPE.pathnode, noone) .setVisible(true, true); - inputs[| 1] = nodeValue("Frequency", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4); + inputs[| 1] = nodeValue("Frequency", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 4, 4 ]) + .setDisplay(VALUE_DISPLAY.range, { linked : true }); - inputs[| 2] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4); + inputs[| 2] = nodeValue("Amplitude", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 4, 4 ]) + .setDisplay(VALUE_DISPLAY.range, { linked : true }); - inputs[| 3] = nodeValue("Shift", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0); + inputs[| 3] = nodeValue("Shift", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ]) + .setDisplay(VALUE_DISPLAY.range, { linked : true }); inputs[| 4] = nodeValue("Smooth", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + inputs[| 5] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, seed_random()); + + inputs[| 6] = nodeValue("Wiggle", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + + inputs[| 7] = nodeValue("Wiggle Amplitude", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ -2, 2 ]) + .setDisplay(VALUE_DISPLAY.range, { linked : true }); + + inputs[| 8] = nodeValue("Wiggle Frequency", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 8); + + inputs[| 9] = nodeValue("Amplitude over length", self, JUNCTION_CONNECT.input, VALUE_TYPE.curve, CURVE_DEF_11); + outputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.output, VALUE_TYPE.pathnode, self); - input_display_list = [ + input_display_list = [ 5, ["Path", true], 0, - ["Wave", false], 1, 2, 3, 4, - ] + ["Wave", false], 1, 2, 9, 3, 4, + ["Wiggle", true, 6], 7, 8, + ]; - static getLineCount = function() { - var _path = getInputData(0); - return struct_has(_path, "getLineCount")? _path.getLineCount() : 1; - } + path = 0; + fre = 0; + amp = 0; + shf = 0; + smt = 0; + seed = 0; - static getSegmentCount = function(ind = 0) { - var _path = getInputData(0); - return struct_has(_path, "getSegmentCount")? _path.getSegmentCount(ind) : 0; - } - - static getLength = function(ind = 0) { - var _path = getInputData(0); - var _fre = getInputData(1); _fre = max(1, abs(_fre)); - var _amo = getInputData(2); + wig = 0 + wigs = 0 + wigf = 0 - var _len = struct_has(_path, "getLength")? _path.getLength(ind) : 0; - _len *= _fre * sqrt(_amo + 1 / _fre); + wig_map = noone; + amp_curve = noone; + p0 = new __vec2(); + p = new __vec2(); + p1 = new __vec2(); + + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + var _path = getInputData(0); + if(_path) _path.drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); + + draw_set_color(COLORS._main_icon); + + var _amo = getLineCount(); + + for( var i = 0; i < _amo; i++ ) { + var _len = getLength(i); + var _stp = 1 / clamp(_len * _s, 1, 64); + var ox, oy, nx, ny; + var _p = new __vec2(); + + for( var j = 0; j < 1; j += _stp ) { + _p = getPointRatio(j, i, _p); + nx = _x + _p.x * _s; + ny = _y + _p.y * _s; + + if(j > 0) draw_line_width(ox, oy, nx, ny, 3); + + ox = nx; + oy = ny; + } + } + } #endregion + + static getLineCount = function() { #region + return struct_has(path, "getLineCount")? path.getLineCount() : 1; + } #endregion + + static getSegmentCount = function(ind = 0) { #region + return struct_has(path, "getSegmentCount")? path.getSegmentCount(ind) : 0; + } #endregion + + static getLength = function(ind = 0) { #region + var _fre = fre ; _fre = max(_fre[0], _fre[1]); + var _amo = amp ; _amo = max(_amo[0], _amo[1]); + + _fre = max(1, abs(_fre)); + var _len = struct_has(path, "getLength")? path.getLength(ind) : 0; + _len *= _fre * sqrt(abs(_amo) + 1 / _fre); return _len; - } + } #endregion - static getAccuLength = function(ind = 0) { - var _path = getInputData(0); - var _fre = getInputData(1); _fre = max(1, abs(_fre)); - var _amo = getInputData(2); + static getAccuLength = function(ind = 0) { #region + var _fre = fre ; _fre = max(_fre[0], _fre[1]); + var _amo = amp ; _amo = max(_amo[0], _amo[1]); - var _len = struct_has(_path, "getAccuLength")? _path.getAccuLength(ind) : []; - var _mul = _fre * sqrt(_amo + 1 / _fre); + _fre = max(1, abs(_fre)); + var _len = struct_has(path, "getAccuLength")? path.getAccuLength(ind) : []; + var _mul = _fre * sqrt(abs(_amo) + 1 / _fre); for( var i = 0, n = array_length(_len); i < n; i++ ) _len[i] *= _mul; return _len; - } + } #endregion - static getPointRatio = function(_rat, ind = 0, out = undefined) { + static getPointRatio = function(_rat, ind = 0, out = undefined) { #region if(out == undefined) out = new __vec2(); else { out.x = 0; out.y = 0; } - var _path = getInputData(0); - var _fre = getInputData(1); _fre = max(0.01, abs(_fre)); - var _amo = getInputData(2); - var _shf = getInputData(3); - var _smt = getInputData(4); + var _path = path; + var _fre = fre ; + var _amp = amp ; + var _shf = shf ; + var _smt = smt ; + var _seed = seed + ind; + + var _wig = wig ; + var _wigs = wigs; + var _wigf = wigf; + + _amp = random_range_seed(_amp[0], _amp[1], _seed + ind); + _shf = random_range_seed(_shf[0], _shf[1], _seed + 1 + ind); + _fre = random_range_seed(_fre[0], _fre[1], _seed + 2 + ind); + + _fre = max(0.01, abs(_fre)); + var _t = _shf + _rat * _fre; + + if(_wig) { + var _w = wiggle(_wigs[0], _wigs[1], _wigf, _t, _seed); + _amp += _w; + } if(is_array(_path)) { _path = array_safe_get(_path, ind); @@ -73,35 +146,51 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) construct if(!is_struct(_path) || !struct_has(_path, "getPointRatio")) return out; - var _p0 = _path.getPointRatio(clamp(_rat - 0.001, 0, 0.999999), ind); - var _p = _path.getPointRatio(_rat, ind).clone(); - var _p1 = _path.getPointRatio(clamp(_rat + 0.001, 0, 0.999999), ind); + p0 = _path.getPointRatio(clamp(_rat - 0.001, 0, 0.999999), ind, p0); + p = _path.getPointRatio(_rat, ind, p); + p1 = _path.getPointRatio(clamp(_rat + 0.001, 0, 0.999999), ind, p1); - var dir = point_direction(_p0.x, _p0.y, _p1.x, _p1.y) + 90; + var dir = point_direction(p0.x, p0.y, p1.x, p1.y) + 90; var prg; - if(_smt) prg = cos((_shf + _rat * _fre) * pi * 2); - else prg = (abs(frac(_shf + _rat * _fre) * 2 - 1) - 0.5) * 2; + if(_smt) prg = cos(_t * pi * 2); + else prg = (abs(frac(_t) * 2 - 1) - 0.5) * 2; - out.x = _p.x + lengthdir_x(prg * _amo, dir); - out.y = _p.y + lengthdir_y(prg * _amo, dir); + if(amp_curve) prg *= amp_curve.get(_rat); + + out.x = p.x + lengthdir_x(_amp * prg, dir); + out.y = p.y + lengthdir_y(_amp * prg, dir); return out; - } + } #endregion static getPointDistance = function(_dist, ind = 0, out = undefined) { return getPointRatio(_dist / getLength(), ind, out); } - static getBoundary = function(ind = 0) { - var _path = getInputData(0); - return struct_has(_path, "getBoundary")? _path.getBoundary(ind) : new BoundingBox( 0, 0, 1, 1 ); - } + static getBoundary = function(ind = 0) { #region + return struct_has(path, "getBoundary")? path.getBoundary(ind) : new BoundingBox( 0, 0, 1, 1 ); + } #endregion - static update = function() { + static update = function() { #region + path = getInputData(0); + fre = getInputData(1); + amp = getInputData(2); + shf = getInputData(3); + smt = getInputData(4); + seed = getInputData(5); + + wig = getInputData(6); + wigs = getInputData(7); + wigf = getInputData(8); + + var _ampc = getInputData(9); + + amp_curve = new curveMap(_ampc, 128); + outputs[| 0].setValue(self); - } + } #endregion - static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region var bbox = drawGetBbox(xx, yy, _s); draw_sprite_fit(s_node_path_wave, 0, bbox.xc, bbox.yc, bbox.w, bbox.h); - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_simple_shape/node_simple_shape.gml b/scripts/node_simple_shape/node_simple_shape.gml index 965d0ff7c..17f86adf7 100644 --- a/scripts/node_simple_shape/node_simple_shape.gml +++ b/scripts/node_simple_shape/node_simple_shape.gml @@ -59,11 +59,14 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con inputs[| 18] = nodeValue("Tile", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + inputs[| 19] = nodeValue("Shape Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) + .setDisplay(VALUE_DISPLAY.rotation); + outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); input_display_list = [ ["Output", false], 0, 6, - ["Transform", false], 15, 3, 16, 17, + ["Transform", false], 15, 3, 16, 17, 19, ["Shape", false], 14, 2, 9, 4, 13, 5, 7, 8, ["Render", true], 10, 12, 18, ["Background", true, 1], 11, @@ -105,6 +108,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con var _posTyp = _data[15]; var _tile = _data[18]; + var _rotat = _data[19]; var _center = [ 0, 0 ]; var _scale = [ 0, 0 ]; @@ -275,7 +279,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con break; case NODE_SHAPE_TYPE.crescent : inputs[| 5].setVisible(true); - inputs[| 7].setVisible(true); + inputs[| 7].setVisible(true); inputs[| 13].setVisible(true); inputs[| 5].name = "Shift"; @@ -304,6 +308,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con shader_set_f("center", _center); shader_set_f("scale", _scale ); + shader_set_f("rotation", degtorad(_rotat)); draw_sprite_stretched_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], _color, _color_get_alpha(_color)); surface_reset_shader(); diff --git a/scripts/panel_inspector/panel_inspector.gml b/scripts/panel_inspector/panel_inspector.gml index a32a28bcb..28bfb0b55 100644 --- a/scripts/panel_inspector/panel_inspector.gml +++ b/scripts/panel_inspector/panel_inspector.gml @@ -702,21 +702,8 @@ function Panel_Inspector() : PanelContent() constructor { } #region color picker - //if(color_picker_selecting == noone) - // picker_selecting = 0; - - if(key_mod_press(ALT) && color_picker_index) { + if(key_mod_press(ALT) && color_picker_index && textBox_slider.tb == noone) { pickers[picker_index].editWidget.onColorPick(); - - //var _p = picker_index; - - //if(mouse_wheel_down()) picker_index = safe_mod(picker_index + 1 + color_picker_index, color_picker_index); - //if(mouse_wheel_up()) picker_index = safe_mod(picker_index - 1 + color_picker_index, color_picker_index); - - //if(_p != picker_index) { - // instance_destroy(o_dialog_color_selector); - // pickers[picker_index].editWidget.onColorPick(); - //} } if(MESSAGE != noone && MESSAGE.type == "Color") { diff --git a/scripts/random_function/random_function.gml b/scripts/random_function/random_function.gml index 96a8a2bd8..aa5e7388e 100644 --- a/scripts/random_function/random_function.gml +++ b/scripts/random_function/random_function.gml @@ -121,23 +121,26 @@ function wiggleMap(_seed, _freq, _length) constructor { #region len = _length; amp = 1; map = array_create(_length); + shf = 0; static generate = function() { INLINE - for(var i = 0; i < len; i++) map[i] = wiggle(-1, 1, freq, i, seed); + for(var i = 0; i < len; i++) map[i] = wiggle(-1, 1, freq, i + shf, seed); } - static check = function(_amp, _freq, _seed) { + static check = function(_amp, _freq, _seed, _shf = 0) { INLINE amp = _amp; - if(seed == _seed && freq == _freq) return; + if(seed == _seed && freq == _freq && shf == _shf) return; - //print($"Check {seed}:{_seed}, {freq}:{_freq} ({irandom(999999)})"); seed = _seed; freq = _freq; + shf = _shf; generate(); + + return self; } static get = function(i) { diff --git a/shaders/sh_shape/sh_shape.fsh b/shaders/sh_shape/sh_shape.fsh index b1d20c945..9b3f140c5 100644 --- a/shaders/sh_shape/sh_shape.fsh +++ b/shaders/sh_shape/sh_shape.fsh @@ -10,6 +10,7 @@ uniform int sides; uniform int drawDF; uniform int tile; +uniform float rotation; uniform float angle; uniform float inner; uniform float outer; @@ -125,14 +126,14 @@ float sdDonut(vec2 p, float s) { #region void main() { float color = 0.; - vec2 coord = (v_vTexcoord - center) / scale; + vec2 coord = (v_vTexcoord - center) * mat2(cos(rotation), -sin(rotation), sin(rotation), cos(rotation)) / scale; vec2 ratio = dimension / dimension.y; float d; if(tile == 1) coord = mod(coord + 1., 2.) - 1.; if(shape == 0) { - d = sdBox( (v_vTexcoord - center) * ratio, (scale * ratio - corner)); + d = sdBox( (v_vTexcoord - center) * mat2(cos(rotation), -sin(rotation), sin(rotation), cos(rotation)) * ratio, (scale * ratio - corner)); d -= corner; } else if(shape == 1) { d = length(coord) - 1.;