mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-24 03:48:06 +01:00
New Shape Path node.
This commit is contained in:
parent
989468f27b
commit
1ce0c47f18
11 changed files with 503 additions and 28 deletions
|
@ -983,28 +983,29 @@
|
|||
{"name":"node_palette_sort","order":9,"path":"scripts/node_palette_sort/node_palette_sort.yy",},
|
||||
{"name":"node_palette","order":4,"path":"scripts/node_palette/node_palette.yy",},
|
||||
{"name":"node_particle","order":11,"path":"scripts/node_particle/node_particle.yy",},
|
||||
{"name":"node_path_3d","order":20,"path":"scripts/node_path_3d/node_path_3d.yy",},
|
||||
{"name":"node_path_anchor","order":13,"path":"scripts/node_path_anchor/node_path_anchor.yy",},
|
||||
{"name":"node_path_array","order":11,"path":"scripts/node_path_array/node_path_array.yy",},
|
||||
{"name":"node_path_bake","order":15,"path":"scripts/node_path_bake/node_path_bake.yy",},
|
||||
{"name":"node_path_blend","order":2,"path":"scripts/node_path_blend/node_path_blend.yy",},
|
||||
{"name":"node_path_bridge","order":16,"path":"scripts/node_path_bridge/node_path_bridge.yy",},
|
||||
{"name":"node_path_builder","order":9,"path":"scripts/node_path_builder/node_path_builder.yy",},
|
||||
{"name":"node_path_from_mask","order":14,"path":"scripts/node_path_from_mask/node_path_from_mask.yy",},
|
||||
{"name":"node_path_l_system","order":10,"path":"scripts/node_path_l_system/node_path_l_system.yy",},
|
||||
{"name":"node_path_map_area","order":1,"path":"scripts/node_path_map_area/node_path_map_area.yy",},
|
||||
{"name":"node_path_map","order":17,"path":"scripts/node_path_map/node_path_map.yy",},
|
||||
{"name":"node_path_plot","order":12,"path":"scripts/node_path_plot/node_path_plot.yy",},
|
||||
{"name":"node_path_3d","order":1,"path":"scripts/node_path_3d/node_path_3d.yy",},
|
||||
{"name":"node_path_anchor","order":15,"path":"scripts/node_path_anchor/node_path_anchor.yy",},
|
||||
{"name":"node_path_array","order":13,"path":"scripts/node_path_array/node_path_array.yy",},
|
||||
{"name":"node_path_bake","order":17,"path":"scripts/node_path_bake/node_path_bake.yy",},
|
||||
{"name":"node_path_blend","order":5,"path":"scripts/node_path_blend/node_path_blend.yy",},
|
||||
{"name":"node_path_bridge","order":18,"path":"scripts/node_path_bridge/node_path_bridge.yy",},
|
||||
{"name":"node_path_builder","order":11,"path":"scripts/node_path_builder/node_path_builder.yy",},
|
||||
{"name":"node_path_from_mask","order":16,"path":"scripts/node_path_from_mask/node_path_from_mask.yy",},
|
||||
{"name":"node_path_l_system","order":12,"path":"scripts/node_path_l_system/node_path_l_system.yy",},
|
||||
{"name":"node_path_map_area","order":4,"path":"scripts/node_path_map_area/node_path_map_area.yy",},
|
||||
{"name":"node_path_map","order":19,"path":"scripts/node_path_map/node_path_map.yy",},
|
||||
{"name":"node_path_plot","order":14,"path":"scripts/node_path_plot/node_path_plot.yy",},
|
||||
{"name":"node_path_profile","order":10,"path":"scripts/node_path_profile/node_path_profile.yy",},
|
||||
{"name":"node_path_reverse","order":8,"path":"scripts/node_path_reverse/node_path_reverse.yy",},
|
||||
{"name":"node_path_sample","order":4,"path":"scripts/node_path_sample/node_path_sample.yy",},
|
||||
{"name":"node_path_scatter","order":19,"path":"scripts/node_path_scatter/node_path_scatter.yy",},
|
||||
{"name":"node_path_reverse","order":10,"path":"scripts/node_path_reverse/node_path_reverse.yy",},
|
||||
{"name":"node_path_sample","order":6,"path":"scripts/node_path_sample/node_path_sample.yy",},
|
||||
{"name":"node_path_scatter","order":21,"path":"scripts/node_path_scatter/node_path_scatter.yy",},
|
||||
{"name":"node_path_separate_folder","order":12,"path":"scripts/node_path_separate_folder/node_path_separate_folder.yy",},
|
||||
{"name":"node_path_shift","order":5,"path":"scripts/node_path_shift/node_path_shift.yy",},
|
||||
{"name":"node_path_smooth","order":18,"path":"scripts/node_path_smooth/node_path_smooth.yy",},
|
||||
{"name":"node_path_trim","order":6,"path":"scripts/node_path_trim/node_path_trim.yy",},
|
||||
{"name":"node_path_wave","order":7,"path":"scripts/node_path_wave/node_path_wave.yy",},
|
||||
{"name":"node_path","order":3,"path":"scripts/node_path/node_path.yy",},
|
||||
{"name":"node_path_shape","order":2,"path":"scripts/node_path_shape/node_path_shape.yy",},
|
||||
{"name":"node_path_shift","order":7,"path":"scripts/node_path_shift/node_path_shift.yy",},
|
||||
{"name":"node_path_smooth","order":20,"path":"scripts/node_path_smooth/node_path_smooth.yy",},
|
||||
{"name":"node_path_transform","order":3,"path":"scripts/node_path_transform/node_path_transform.yy",},
|
||||
{"name":"node_path_trim","order":8,"path":"scripts/node_path_trim/node_path_trim.yy",},
|
||||
{"name":"node_path_wave","order":9,"path":"scripts/node_path_wave/node_path_wave.yy",},
|
||||
{"name":"node_pb_box_contract","order":8,"path":"scripts/node_pb_box_contract/node_pb_box_contract.yy",},
|
||||
{"name":"node_pb_box_divide_grid","order":7,"path":"scripts/node_pb_box_divide_grid/node_pb_box_divide_grid.yy",},
|
||||
{"name":"node_pb_box_divide","order":5,"path":"scripts/node_pb_box_divide/node_pb_box_divide.yy",},
|
||||
|
@ -1093,7 +1094,7 @@
|
|||
{"name":"node_scale","order":8,"path":"scripts/node_scale/node_scale.yy",},
|
||||
{"name":"node_scatter_points","order":7,"path":"scripts/node_scatter_points/node_scatter_points.yy",},
|
||||
{"name":"node_scatter","order":10,"path":"scripts/node_scatter/node_scatter.yy",},
|
||||
{"name":"node_segment_filter","order":21,"path":"scripts/node_segment_filter/node_segment_filter.yy",},
|
||||
{"name":"node_segment_filter","order":22,"path":"scripts/node_segment_filter/node_segment_filter.yy",},
|
||||
{"name":"node_sequence_anim","order":5,"path":"scripts/node_sequence_anim/node_sequence_anim.yy",},
|
||||
{"name":"node_shadow_cast","order":15,"path":"scripts/node_shadow_cast/node_shadow_cast.yy",},
|
||||
{"name":"node_shadow","order":14,"path":"scripts/node_shadow/node_shadow.yy",},
|
||||
|
@ -2429,6 +2430,7 @@
|
|||
{"name":"s_node_path_reverse","order":12,"path":"sprites/s_node_path_reverse/s_node_path_reverse.yy",},
|
||||
{"name":"s_node_path_sample","order":13,"path":"sprites/s_node_path_sample/s_node_path_sample.yy",},
|
||||
{"name":"s_node_path_scatter","order":19,"path":"sprites/s_node_path_scatter/s_node_path_scatter.yy",},
|
||||
{"name":"s_node_path_shape","order":22,"path":"sprites/s_node_path_shape/s_node_path_shape.yy",},
|
||||
{"name":"s_node_path_shift","order":14,"path":"sprites/s_node_path_shift/s_node_path_shift.yy",},
|
||||
{"name":"s_node_path_smooth","order":15,"path":"sprites/s_node_path_smooth/s_node_path_smooth.yy",},
|
||||
{"name":"s_node_path_transform","order":16,"path":"sprites/s_node_path_transform/s_node_path_transform.yy",},
|
||||
|
|
|
@ -1537,6 +1537,7 @@
|
|||
{"id":{"name":"node_path_sample","path":"scripts/node_path_sample/node_path_sample.yy",},},
|
||||
{"id":{"name":"node_path_scatter","path":"scripts/node_path_scatter/node_path_scatter.yy",},},
|
||||
{"id":{"name":"node_path_separate_folder","path":"scripts/node_path_separate_folder/node_path_separate_folder.yy",},},
|
||||
{"id":{"name":"node_path_shape","path":"scripts/node_path_shape/node_path_shape.yy",},},
|
||||
{"id":{"name":"node_path_shift","path":"scripts/node_path_shift/node_path_shift.yy",},},
|
||||
{"id":{"name":"node_path_smooth","path":"scripts/node_path_smooth/node_path_smooth.yy",},},
|
||||
{"id":{"name":"node_path_transform","path":"scripts/node_path_transform/node_path_transform.yy",},},
|
||||
|
@ -3122,6 +3123,7 @@
|
|||
{"id":{"name":"s_node_path_reverse","path":"sprites/s_node_path_reverse/s_node_path_reverse.yy",},},
|
||||
{"id":{"name":"s_node_path_sample","path":"sprites/s_node_path_sample/s_node_path_sample.yy",},},
|
||||
{"id":{"name":"s_node_path_scatter","path":"sprites/s_node_path_scatter/s_node_path_scatter.yy",},},
|
||||
{"id":{"name":"s_node_path_shape","path":"sprites/s_node_path_shape/s_node_path_shape.yy",},},
|
||||
{"id":{"name":"s_node_path_shift","path":"sprites/s_node_path_shift/s_node_path_shift.yy",},},
|
||||
{"id":{"name":"s_node_path_smooth","path":"sprites/s_node_path_smooth/s_node_path_smooth.yy",},},
|
||||
{"id":{"name":"s_node_path_transform","path":"sprites/s_node_path_transform/s_node_path_transform.yy",},},
|
||||
|
|
|
@ -118,7 +118,6 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
|
|||
|
||||
for (var i = 2, n = array_length(inputs); i < n; i++)
|
||||
inputs[i].rejectArray();
|
||||
|
||||
input_len = array_length(inputs);
|
||||
|
||||
input_display_list = [ 32, 48,
|
||||
|
|
349
scripts/node_path_shape/node_path_shape.gml
Normal file
349
scripts/node_path_shape/node_path_shape.gml
Normal file
|
@ -0,0 +1,349 @@
|
|||
function Node_Path_Shape(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Path Shape";
|
||||
setDimension(96, 48);
|
||||
|
||||
newInput(0, nodeValue_Vec2("Position", self, [ 0, 0 ]));
|
||||
|
||||
newInput(1, nodeValue_Vec2("Half Size", self, [ 32, 32 ]));
|
||||
|
||||
newInput(2, nodeValue_Rotation("Rotation", self, 0));
|
||||
|
||||
shapeScroll = [
|
||||
new scrollItem("Rectangle", s_node_shape_type, 0),
|
||||
new scrollItem("Trapezoid", s_node_shape_type, 2),
|
||||
new scrollItem("Parallelogram", s_node_shape_type, 3),
|
||||
-1,
|
||||
new scrollItem("Ellipse", s_node_shape_type, 5),
|
||||
new scrollItem("Arc", s_node_shape_type, 6),
|
||||
new scrollItem("Squircle", s_node_shape_type, 11),
|
||||
-1,
|
||||
new scrollItem("Polygon", s_node_shape_type, 12),
|
||||
new scrollItem("Star", s_node_shape_type, 13),
|
||||
];
|
||||
newInput(3, nodeValue_Enum_Scroll("Shape", self, 0, shapeScroll));
|
||||
|
||||
newInput(4, nodeValue_Float("Skew", self, .5))
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01] });
|
||||
|
||||
newInput(5, nodeValue_Rotation_Range("Angle Range", self, [ 0, 90 ]));
|
||||
|
||||
newInput(6, nodeValue_Float("Factor", self, 4));
|
||||
|
||||
newInput(7, nodeValue_Int("Sides", self, 4));
|
||||
|
||||
newInput(8, nodeValue_Float("Inner Radius", self, .5));
|
||||
|
||||
newOutput(0, nodeValue_Output("Path data", self, VALUE_TYPE.pathnode, self));
|
||||
|
||||
input_display_list = [
|
||||
["Transform", false], 0, 2, 1,
|
||||
["Shape", false], 3, 4, 5, 6, 7, 8,
|
||||
];
|
||||
|
||||
points = [];
|
||||
lengths = [];
|
||||
lengthAccs = [];
|
||||
lengthTotal = 0;
|
||||
boundary = new BoundingBox();
|
||||
cached_pos = ds_map_create();
|
||||
|
||||
shape = 0;
|
||||
posx = 0; posy = 0;
|
||||
scax = 1; scay = 1;
|
||||
rot = 0;
|
||||
|
||||
pa1 = 0;
|
||||
pa2x = 0; pa2y = 0;
|
||||
pa3 = 0;
|
||||
|
||||
static getLineCount = function() /*=>*/ {return 1};
|
||||
static getSegmentCount = function() /*=>*/ {return array_length(lengths)};
|
||||
static getBoundary = function() /*=>*/ {return boundary};
|
||||
static getLength = function() /*=>*/ {return lengthTotal};
|
||||
static getAccuLength = function() /*=>*/ {return lengthAccs};
|
||||
|
||||
static getPointRatio = function(_rat, _ind = 0, out = undefined) {
|
||||
if(out == undefined) out = new __vec2();
|
||||
_rat = frac(_rat);
|
||||
|
||||
switch(shapeScroll[shape].name) {
|
||||
case "Rectangle" :
|
||||
case "Trapezoid" :
|
||||
case "Parallelogram" :
|
||||
if(_rat <= .25) {
|
||||
var r = _rat * 4;
|
||||
out.x = lerp(points[0][0], points[1][0], r);
|
||||
out.y = lerp(points[0][1], points[1][1], r);
|
||||
} else if(_rat <= .50) {
|
||||
var r = (_rat - .25) * 4;
|
||||
out.x = lerp(points[1][0], points[2][0], r);
|
||||
out.y = lerp(points[1][1], points[2][1], r);
|
||||
} else if(_rat <= .75) {
|
||||
var r = (_rat - .50) * 4;
|
||||
out.x = lerp(points[2][0], points[3][0], r);
|
||||
out.y = lerp(points[2][1], points[3][1], r);
|
||||
} else {
|
||||
var r = (_rat - .75) * 4;
|
||||
out.x = lerp(points[3][0], points[0][0], r);
|
||||
out.y = lerp(points[3][1], points[0][1], r);
|
||||
}
|
||||
break;
|
||||
|
||||
case "Ellipse" :
|
||||
var a = 360 * _rat;
|
||||
out.x = posx + lengthdir_x(scax, a);
|
||||
out.y = posy + lengthdir_y(scay, a);
|
||||
break;
|
||||
|
||||
case "Arc" :
|
||||
var a = lerp_angle(pa2x, pa2y, _rat);
|
||||
out.x = posx + lengthdir_x(scax, a);
|
||||
out.y = posy + lengthdir_y(scay, a);
|
||||
break;
|
||||
|
||||
case "Squircle" :
|
||||
var a = 360 * _rat;
|
||||
var r = 1 / power(power(dcos(a % 90), pa3) + power(dsin(a % 90), pa3), 1 / pa3);
|
||||
|
||||
out.x = posx + lengthdir_x(scax * r, a);
|
||||
out.y = posy + lengthdir_y(scay * r, a);
|
||||
break;
|
||||
|
||||
case "Polygon" :
|
||||
case "Star" : return getPointDistance(_rat * lengthTotal, _ind, out);
|
||||
|
||||
}
|
||||
|
||||
point_vec2_rotate(out, posx, posy, rot);
|
||||
return out;
|
||||
}
|
||||
|
||||
static getPointDistance = function(_dist, _ind = 0, out = undefined) {
|
||||
if(out == undefined) out = new __vec2();
|
||||
_dist = safe_mod(_dist, lengthTotal);
|
||||
|
||||
var _d = _dist, l;
|
||||
var np = array_length(points);
|
||||
|
||||
for( var i = 0, n = array_length(lengths); i < n; i++ ) {
|
||||
l = lengths[i];
|
||||
if(_d > l) { _d -= l; continue; }
|
||||
|
||||
var p0 = points[(i + 0) % np];
|
||||
var p1 = points[(i + 1) % np];
|
||||
|
||||
out.x = lerp(p0[0], p1[0], _d / l);
|
||||
out.y = lerp(p0[1], p1[1], _d / l);
|
||||
break;
|
||||
}
|
||||
|
||||
point_vec2_rotate(out, posx, posy, rot);
|
||||
return out;
|
||||
}
|
||||
|
||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||
if(array_empty(points)) return;
|
||||
|
||||
var ox = _x + points[0][0] * _s, x0 = ox;
|
||||
var oy = _y + points[0][1] * _s, y0 = oy;
|
||||
var nx, ny;
|
||||
|
||||
draw_set_color(COLORS._main_accent);
|
||||
for( var i = 1, n = array_length(points); i < n; i++ ) {
|
||||
nx = _x + points[i][0] * _s;
|
||||
ny = _y + points[i][1] * _s;
|
||||
|
||||
draw_line(ox, oy, nx, ny);
|
||||
|
||||
ox = nx;
|
||||
oy = ny;
|
||||
}
|
||||
|
||||
draw_line(ox, oy, x0, y0);
|
||||
|
||||
var _px = _x + posx * _s;
|
||||
var _py = _y + posy * _s;
|
||||
|
||||
var h = inputs[0].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); hover &= !h;
|
||||
var h = inputs[2].drawOverlay(hover, active, _px, _py, _s, _mx, _my, _snx, _sny); hover &= !h;
|
||||
var h = inputs[1].drawOverlay(hover, active, _px, _py, _s, _mx, _my, _snx, _sny); hover &= !h;
|
||||
|
||||
}
|
||||
|
||||
static update = function(frame = CURRENT_FRAME) {
|
||||
var _pos = inputs[0].getValue();
|
||||
var _rot = inputs[2].getValue();
|
||||
var _sca = inputs[1].getValue();
|
||||
var _pa1 = inputs[4].getValue();
|
||||
var _aran = inputs[5].getValue();
|
||||
var _pa3 = inputs[6].getValue();
|
||||
var _sid = inputs[7].getValue();
|
||||
var _inn = inputs[8].getValue();
|
||||
|
||||
shape = inputs[3].getValue();
|
||||
posx = _pos[0];
|
||||
posy = _pos[1];
|
||||
rot = _rot;
|
||||
scax = _sca[0];
|
||||
scay = _sca[1];
|
||||
|
||||
pa1 = _pa1;
|
||||
pa2x = _aran[0];
|
||||
pa2y = _aran[1];
|
||||
pa3 = _pa3;
|
||||
|
||||
var ox, oy, nx, ny, x0, y0;
|
||||
|
||||
inputs[4].setVisible(false);
|
||||
inputs[5].setVisible(false);
|
||||
inputs[6].setVisible(false);
|
||||
inputs[7].setVisible(false);
|
||||
inputs[8].setVisible(false);
|
||||
|
||||
switch(shapeScroll[shape].name) {
|
||||
case "Rectangle" :
|
||||
points = [
|
||||
[ posx - scax, posy - scay ],
|
||||
[ posx + scax, posy - scay ],
|
||||
[ posx + scax, posy + scay ],
|
||||
[ posx - scax, posy + scay ],
|
||||
];
|
||||
break;
|
||||
|
||||
case "Trapezoid" :
|
||||
inputs[4].setVisible(true);
|
||||
|
||||
points = [
|
||||
[ posx - scax * saturate(1 - _pa1), posy - scay ],
|
||||
[ posx + scax * saturate(1 - _pa1), posy - scay ],
|
||||
[ posx + scax * saturate(1 + _pa1), posy + scay ],
|
||||
[ posx - scax * saturate(1 + _pa1), posy + scay ],
|
||||
];
|
||||
break;
|
||||
|
||||
case "Parallelogram" :
|
||||
inputs[4].setVisible(true);
|
||||
|
||||
points = [
|
||||
[ posx - scax * saturate(1 - _pa1), posy - scay ],
|
||||
[ posx + scax * saturate(1 + _pa1), posy - scay ],
|
||||
[ posx + scax * saturate(1 - _pa1), posy + scay ],
|
||||
[ posx - scax * saturate(1 + _pa1), posy + scay ],
|
||||
];
|
||||
break;
|
||||
|
||||
case "Ellipse" :
|
||||
var _st = 64;
|
||||
var _as = 360 / _st;
|
||||
points = array_create(_st);
|
||||
|
||||
for( var i = 0; i < _st; i++ ) {
|
||||
nx = posx + lengthdir_x(scax, _as * i);
|
||||
ny = posy + lengthdir_y(scay, _as * i);
|
||||
points[i] = [ nx, ny ];
|
||||
}
|
||||
break;
|
||||
|
||||
case "Arc" :
|
||||
inputs[5].setVisible(true);
|
||||
|
||||
var _st = 64;
|
||||
var _as = 1 / (_st - 63);
|
||||
points = array_create(_st);
|
||||
|
||||
for( var i = 0; i < _st; i++ ) {
|
||||
var a = lerp_angle(_aran[0], _aran[1], i * _as);
|
||||
nx = posx + lengthdir_x(scax, a);
|
||||
ny = posy + lengthdir_y(scay, a);
|
||||
points[i] = [ nx, ny ];
|
||||
}
|
||||
break;
|
||||
|
||||
case "Squircle" :
|
||||
inputs[6].setVisible(true);
|
||||
|
||||
var _st = 64;
|
||||
var _as = 360 / _st;
|
||||
points = array_create(_st);
|
||||
|
||||
for( var i = 0; i < _st; i++ ) {
|
||||
var a = _as * i;
|
||||
var r = 1 / power(power(dcos(a % 90), pa3) + power(dsin(a % 90), pa3), 1 / pa3);
|
||||
|
||||
nx = posx + lengthdir_x(scax * r, a);
|
||||
ny = posy + lengthdir_y(scay * r, a);
|
||||
points[i] = [ nx, ny ];
|
||||
}
|
||||
break;
|
||||
|
||||
case "Polygon" :
|
||||
inputs[7].setVisible(true);
|
||||
|
||||
var _st = _sid;
|
||||
var _as = 360 / _st;
|
||||
points = array_create(_st);
|
||||
|
||||
for( var i = 0; i < _st; i++ ) {
|
||||
nx = posx + lengthdir_x(scax, _as * i);
|
||||
ny = posy + lengthdir_y(scay, _as * i);
|
||||
points[i] = [ nx, ny ];
|
||||
}
|
||||
break;
|
||||
|
||||
case "Star" :
|
||||
inputs[7].setVisible(true);
|
||||
inputs[8].setVisible(true);
|
||||
|
||||
var _st = _sid;
|
||||
var _as = 360 / _st;
|
||||
points = array_create(_st * 2);
|
||||
|
||||
for( var i = 0; i < _st; i++ ) {
|
||||
nx = posx + lengthdir_x(scax, _as * i);
|
||||
ny = posy + lengthdir_y(scay, _as * i);
|
||||
points[i * 2 + 0] = [ nx, ny ];
|
||||
|
||||
nx = posx + lengthdir_x(scax * _inn, _as * i + _as / 2);
|
||||
ny = posy + lengthdir_y(scay * _inn, _as * i + _as / 2);
|
||||
points[i * 2 + 1] = [ nx, ny ];
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
var n = array_length(points);
|
||||
lengths = array_create(n + 1);
|
||||
|
||||
if(n) {
|
||||
for( var i = 0; i < n; i++ ) {
|
||||
nx = points[i][0];
|
||||
ny = points[i][1];
|
||||
|
||||
if(i) lengths[i - 1] = point_distance(ox, oy, nx, ny);
|
||||
else { x0 = nx; y0 = ny; }
|
||||
|
||||
ox = nx;
|
||||
oy = ny;
|
||||
}
|
||||
|
||||
lengths[n - 1] = point_distance(ox, oy, x0, y0);
|
||||
}
|
||||
|
||||
var _len = array_length(lengths);
|
||||
lengthTotal = 0;
|
||||
lengthAccs = array_create(_len);
|
||||
|
||||
for( var i = 0; i < _len; i++ ) {
|
||||
lengthTotal += lengths[i];
|
||||
lengthAccs[i] = lengthTotal;
|
||||
}
|
||||
|
||||
boundary = new BoundingBox(posx - scax, posy - scay, posx + scax, posy + scay);
|
||||
}
|
||||
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||
var bbox = drawGetBbox(xx, yy, _s);
|
||||
}
|
||||
|
||||
static getPreviewBoundingBox = function() { return BBOX().fromBoundingBox(boundary); }
|
||||
}
|
14
scripts/node_path_shape/node_path_shape.yy
Normal file
14
scripts/node_path_shape/node_path_shape.yy
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"$GMScript":"v1",
|
||||
"%Name":"node_path_shape",
|
||||
"isCompatibility":false,
|
||||
"isDnD":false,
|
||||
"name":"node_path_shape",
|
||||
"parent":{
|
||||
"name":"path",
|
||||
"path":"folders/nodes/data/value/path.yy",
|
||||
},
|
||||
"resourceType":"GMScript",
|
||||
"resourceVersion":"2.0",
|
||||
"tags":[],
|
||||
}
|
|
@ -961,6 +961,7 @@ function __initNodes() {
|
|||
ds_list_add(values, "Paths");
|
||||
addNodeObject(values, "Path", s_node_path, "Node_Path", [1, Node_Path],, "Create path using bezier curve.");
|
||||
addNodeObject(values, "Smooth Path", s_node_path_smooth, "Node_Path_Smooth", [1, Node_Path_Smooth], ["path smooth"], "Create path with automatic smoothness.").setVersion(11640);
|
||||
addNodeObject(values, "Shape Path", s_node_path_shape, "Node_Path_Shape", [1, Node_Path_Shape], ["path shape"], "Create path with predefined shape.").setVersion(1_18_05_6);
|
||||
addNodeObject(values, "Path Anchor", s_node_path_anchor, "Node_Path_Anchor", [1, Node_Path_Anchor],, "Create path anchor data.").setVersion(1140);
|
||||
addNodeObject(values, "Path Combine", s_node_path_array, "Node_Path_Array", [1, Node_Path_Array], ["array path"], "Combine multiple path into one.").setVersion(1137);
|
||||
addNodeObject(values, "Sample Path", s_node_path_sample, "Node_Path_Sample", [1, Node_Path_Sample], ["path sample"], "Sample a 2D position from a path");
|
||||
|
|
|
@ -28,4 +28,6 @@ function convertBase(str, fromBase, toBase) {
|
|||
}
|
||||
|
||||
return newStr;
|
||||
}
|
||||
}
|
||||
|
||||
function saturate(_x) { return clamp(_x, 0, 1); }
|
|
@ -1,9 +1,6 @@
|
|||
function point_rotate(px, py, ox, oy, a, p = undefined) {
|
||||
INLINE
|
||||
|
||||
p ??= [ px, py ];
|
||||
|
||||
a = angle_difference(a, 0);
|
||||
if(a == 0) { p[0] = px; p[1] = py; return p; }
|
||||
else if(a == 180) { p[0] = ox + (ox - px); p[1] = oy + (oy - py); return p; }
|
||||
|
||||
|
@ -23,8 +20,8 @@ function point_rotate_origin(px, py, a, p) {
|
|||
INLINE
|
||||
|
||||
a = angle_difference(a, 0);
|
||||
if(a == 0) { p[0] = px; p[1] = py; return p; }
|
||||
else if(a == 180) { p[0] = -px; p[1] = -py; return p; }
|
||||
if(a == 0) { p[0] = px; p[1] = py; return p; }
|
||||
if(a == 180) { p[0] = -px; p[1] = -py; return p; }
|
||||
|
||||
var dc = dcos(-a);
|
||||
var ds = dsin(-a);
|
||||
|
@ -32,5 +29,24 @@ function point_rotate_origin(px, py, a, p) {
|
|||
p[0] = px * dc - py * ds;
|
||||
p[1] = px * ds + py * dc;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
function point_vec2_rotate(p, ox, oy, a) {
|
||||
var px = p.x;
|
||||
var py = p.y;
|
||||
|
||||
if(a == 0) return p;
|
||||
if(a == 180) { p.x = ox + (ox - px); p.y = oy + (oy - py); return p; }
|
||||
|
||||
var cx = px - ox;
|
||||
var cy = py - oy;
|
||||
|
||||
var dc = dcos(-a);
|
||||
var ds = dsin(-a);
|
||||
|
||||
p.x = ox + cx * dc - cy * ds;
|
||||
p.y = oy + cx * ds + cy * dc;
|
||||
|
||||
return p;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
90
sprites/s_node_path_shape/s_node_path_shape.yy
Normal file
90
sprites/s_node_path_shape/s_node_path_shape.yy
Normal file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"$GMSprite":"",
|
||||
"%Name":"s_node_path_shape",
|
||||
"bboxMode":0,
|
||||
"bbox_bottom":62,
|
||||
"bbox_left":4,
|
||||
"bbox_right":62,
|
||||
"bbox_top":4,
|
||||
"collisionKind":1,
|
||||
"collisionTolerance":0,
|
||||
"DynamicTexturePage":false,
|
||||
"edgeFiltering":false,
|
||||
"For3D":false,
|
||||
"frames":[
|
||||
{"$GMSpriteFrame":"","%Name":"fad435bb-d6c6-4cf3-af30-fb05c48a1fb9","name":"fad435bb-d6c6-4cf3-af30-fb05c48a1fb9","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
],
|
||||
"gridX":0,
|
||||
"gridY":0,
|
||||
"height":64,
|
||||
"HTile":false,
|
||||
"layers":[
|
||||
{"$GMImageLayer":"","%Name":"717cf0d6-4518-48fa-922a-59b36c3a7f15","blendMode":0,"displayName":"default","isLocked":false,"name":"717cf0d6-4518-48fa-922a-59b36c3a7f15","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
|
||||
],
|
||||
"name":"s_node_path_shape",
|
||||
"nineSlice":null,
|
||||
"origin":4,
|
||||
"parent":{
|
||||
"name":"path",
|
||||
"path":"folders/nodes/icons/value/path.yy",
|
||||
},
|
||||
"preMultiplyAlpha":false,
|
||||
"resourceType":"GMSprite",
|
||||
"resourceVersion":"2.0",
|
||||
"sequence":{
|
||||
"$GMSequence":"",
|
||||
"%Name":"s_node_path_shape",
|
||||
"autoRecord":true,
|
||||
"backdropHeight":768,
|
||||
"backdropImageOpacity":0.5,
|
||||
"backdropImagePath":"",
|
||||
"backdropWidth":1366,
|
||||
"backdropXOffset":0.0,
|
||||
"backdropYOffset":0.0,
|
||||
"events":{
|
||||
"$KeyframeStore<MessageEventKeyframe>":"",
|
||||
"Keyframes":[],
|
||||
"resourceType":"KeyframeStore<MessageEventKeyframe>",
|
||||
"resourceVersion":"2.0",
|
||||
},
|
||||
"eventStubScript":null,
|
||||
"eventToFunction":{},
|
||||
"length":1.0,
|
||||
"lockOrigin":false,
|
||||
"moments":{
|
||||
"$KeyframeStore<MomentsEventKeyframe>":"",
|
||||
"Keyframes":[],
|
||||
"resourceType":"KeyframeStore<MomentsEventKeyframe>",
|
||||
"resourceVersion":"2.0",
|
||||
},
|
||||
"name":"s_node_path_shape",
|
||||
"playback":1,
|
||||
"playbackSpeed":30.0,
|
||||
"playbackSpeedType":0,
|
||||
"resourceType":"GMSequence",
|
||||
"resourceVersion":"2.0",
|
||||
"showBackdrop":true,
|
||||
"showBackdropImage":false,
|
||||
"timeUnits":1,
|
||||
"tracks":[
|
||||
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"fad435bb-d6c6-4cf3-af30-fb05c48a1fb9","path":"sprites/s_node_path_shape/s_node_path_shape.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"4d80dd5c-352a-4389-97f9-da1cee46dba3","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
|
||||
],
|
||||
"visibleRange":null,
|
||||
"volume":1.0,
|
||||
"xorigin":32,
|
||||
"yorigin":32,
|
||||
},
|
||||
"swatchColours":null,
|
||||
"swfPrecision":0.5,
|
||||
"textureGroupId":{
|
||||
"name":"Default",
|
||||
"path":"texturegroups/Default",
|
||||
},
|
||||
"type":0,
|
||||
"VTile":false,
|
||||
"width":64,
|
||||
}
|
Loading…
Reference in a new issue