mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-24 11:58:05 +01:00
New Array boolean opr node.
This commit is contained in:
parent
7c8543af45
commit
f075d11357
26 changed files with 610 additions and 372 deletions
|
@ -723,6 +723,7 @@
|
|||
{"name":"node_armature_sample","order":13,"path":"scripts/node_armature_sample/node_armature_sample.yy",},
|
||||
{"name":"node_armature","order":9,"path":"scripts/node_armature/node_armature.yy",},
|
||||
{"name":"node_array_add","order":6,"path":"scripts/node_array_add/node_array_add.yy",},
|
||||
{"name":"node_array_boolean_opr","order":23,"path":"scripts/node_array_boolean_opr/node_array_boolean_opr.yy",},
|
||||
{"name":"node_array_composite","order":17,"path":"scripts/node_array_composite/node_array_composite.yy",},
|
||||
{"name":"node_array_convolute","order":16,"path":"scripts/node_array_convolute/node_array_convolute.yy",},
|
||||
{"name":"node_array_copy","order":14,"path":"scripts/node_array_copy/node_array_copy.yy",},
|
||||
|
@ -1929,6 +1930,7 @@
|
|||
{"name":"s_node_armature_sample","order":18,"path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",},
|
||||
{"name":"s_node_armature","order":16,"path":"sprites/s_node_armature/s_node_armature.yy",},
|
||||
{"name":"s_node_array_add","order":1,"path":"sprites/s_node_array_add/s_node_array_add.yy",},
|
||||
{"name":"s_node_array_boolean_opr","order":23,"path":"sprites/s_node_array_boolean_opr/s_node_array_boolean_opr.yy",},
|
||||
{"name":"s_node_array_composite","order":2,"path":"sprites/s_node_array_composite/s_node_array_composite.yy",},
|
||||
{"name":"s_node_array_convolute","order":3,"path":"sprites/s_node_array_convolute/s_node_array_convolute.yy",},
|
||||
{"name":"s_node_array_copy","order":4,"path":"sprites/s_node_array_copy/s_node_array_copy.yy",},
|
||||
|
|
|
@ -1101,6 +1101,7 @@
|
|||
{"$GMIncludedFile":"","%Name":"tooltip_spr.png","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Transform/Node_Warp","name":"tooltip_spr.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Transform/Node_Wrap_Area","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Add","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Boolean_Opr","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Composite","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Convolute","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Copy","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
|
@ -1109,7 +1110,6 @@
|
|||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Get","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Insert","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Length","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Range copy","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Range","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Rearrange","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Remove","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
|
@ -1120,6 +1120,7 @@
|
|||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Shuffle","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Sort","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Split","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Unique copy","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Unique","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array_Zip","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"info.json","CopyToMask":-1,"filePath":"datafiles/data/Nodes/Internal/Values/Array/Node_Array","name":"info.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
|
@ -1883,6 +1884,7 @@
|
|||
{"id":{"name":"node_armature_sample","path":"scripts/node_armature_sample/node_armature_sample.yy",},},
|
||||
{"id":{"name":"node_armature","path":"scripts/node_armature/node_armature.yy",},},
|
||||
{"id":{"name":"node_array_add","path":"scripts/node_array_add/node_array_add.yy",},},
|
||||
{"id":{"name":"node_array_boolean_opr","path":"scripts/node_array_boolean_opr/node_array_boolean_opr.yy",},},
|
||||
{"id":{"name":"node_array_composite","path":"scripts/node_array_composite/node_array_composite.yy",},},
|
||||
{"id":{"name":"node_array_convolute","path":"scripts/node_array_convolute/node_array_convolute.yy",},},
|
||||
{"id":{"name":"node_array_copy","path":"scripts/node_array_copy/node_array_copy.yy",},},
|
||||
|
@ -3253,6 +3255,7 @@
|
|||
{"id":{"name":"s_node_armature_sample","path":"sprites/s_node_armature_sample/s_node_armature_sample.yy",},},
|
||||
{"id":{"name":"s_node_armature","path":"sprites/s_node_armature/s_node_armature.yy",},},
|
||||
{"id":{"name":"s_node_array_add","path":"sprites/s_node_array_add/s_node_array_add.yy",},},
|
||||
{"id":{"name":"s_node_array_boolean_opr","path":"sprites/s_node_array_boolean_opr/s_node_array_boolean_opr.yy",},},
|
||||
{"id":{"name":"s_node_array_composite","path":"sprites/s_node_array_composite/s_node_array_composite.yy",},},
|
||||
{"id":{"name":"s_node_array_convolute","path":"sprites/s_node_array_convolute/s_node_array_convolute.yy",},},
|
||||
{"id":{"name":"s_node_array_copy","path":"sprites/s_node_array_copy/s_node_array_copy.yy",},},
|
||||
|
|
Binary file not shown.
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"color"
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"color"
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"color"
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name":"Array Boolean Opr",
|
||||
"baseNode":"Node_Array_Boolean_Opr",
|
||||
"tooltip":"Apply a boolean operation bewteen two arrays.",
|
||||
"spr":"s_node_array_boolean_opr",
|
||||
"io":[
|
||||
"float"
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"float"
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"float",
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -7,4 +7,5 @@
|
|||
"float",
|
||||
"surface"
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"float",
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"float",
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"float",
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"float",
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"float",
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"float",
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -6,4 +6,5 @@
|
|||
"io":[
|
||||
"float",
|
||||
],
|
||||
"pxc_version":118069,
|
||||
}
|
|
@ -748,6 +748,7 @@
|
|||
"Node_Array_Composite",
|
||||
"Node_Array_Shuffle",
|
||||
"Node_Array_Unique",
|
||||
"Node_Array_Boolean_Opr",
|
||||
{ "label": "/Group Operators" },
|
||||
"Node_Array_Sort",
|
||||
"Node_Iterate_Each_Inline",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#region creation
|
||||
function array_create_2d(_x, _y, val = 0) {
|
||||
var _arr = array_create(_x);
|
||||
for( var i = 0; i < _x; i++ )
|
||||
|
@ -15,47 +16,67 @@ function array_create_from_list(list) {
|
|||
return arr;
|
||||
}
|
||||
|
||||
function array_safe_set(arr, index, value, fill = 0) {
|
||||
function array_clone(arr, _depth = -1) {
|
||||
INLINE
|
||||
|
||||
if(_depth == 0) return arr;
|
||||
if(!is_array(arr)) return arr;
|
||||
if(is_array(index)) return arr;
|
||||
|
||||
if(index < 0) return arr;
|
||||
if(index >= array_length(arr)) {
|
||||
var i = array_length(arr);
|
||||
for(; i <= index; i++ )
|
||||
arr[i] = fill;
|
||||
arr[index] = value;
|
||||
return arr;
|
||||
var _res = [];
|
||||
for( var i = 0, n = array_length(arr); i < n; i++ )
|
||||
_res[i] = array_clone(arr[i], _depth--);
|
||||
|
||||
return _res;
|
||||
}
|
||||
#endregion
|
||||
|
||||
array_set(arr, index, value);
|
||||
return arr;
|
||||
}
|
||||
#region check
|
||||
function array_empty(arr) { INLINE return is_array(arr) && array_length(arr) == 0; }
|
||||
function array_valid(arr) { INLINE return is_array(arr) && array_length(arr) > 0; }
|
||||
function array_invalid(arr) { INLINE return !is_array(arr) || array_length(arr) == 0; }
|
||||
|
||||
function array_safe_length(arr) {
|
||||
INLINE
|
||||
return is_array(arr)? array_length(arr) : 0;
|
||||
}
|
||||
|
||||
function array_fill(arr, startIndex, endIndex, value = 0) {
|
||||
function array_verify_new(arr, length) {
|
||||
INLINE
|
||||
|
||||
for( var i = max(0, startIndex); i < endIndex; i++ )
|
||||
arr[i] = value;
|
||||
}
|
||||
if(!is_array(arr)) return array_create(length);
|
||||
if(array_length(arr) == length) return arr;
|
||||
|
||||
function array_resize_fill(arr, size, fill = 0) {
|
||||
if(size < array_length(arr)) {
|
||||
array_resize(arr, size);
|
||||
arr = array_clone(arr, 1);
|
||||
array_resize(arr, length);
|
||||
return arr;
|
||||
}
|
||||
|
||||
var i = array_length(arr);
|
||||
for(; i < size; i++)
|
||||
arr[i] = fill;
|
||||
function array_verify(arr, length) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return array_create(length);
|
||||
if(array_length(arr) == length) return arr;
|
||||
|
||||
array_resize(arr, length);
|
||||
return arr;
|
||||
}
|
||||
|
||||
function array_verify_ext(arr, length, generator) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return array_create_ext(length, generator);
|
||||
|
||||
var _len = array_length(arr);
|
||||
if(_len == length) return arr;
|
||||
|
||||
array_resize(arr, length);
|
||||
var i = _len;
|
||||
|
||||
repeat(length - _len)
|
||||
arr[i++] = generator();
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region get set
|
||||
|
||||
enum ARRAY_OVERFLOW {
|
||||
_default,
|
||||
loop,
|
||||
|
@ -102,14 +123,6 @@ function array_safe_get(arr, index, def = 0, overflow = ARRAY_OVERFLOW._default)
|
|||
return arr[index] == undefined? def : arr[index];
|
||||
}
|
||||
|
||||
function array_push_create(arr, val) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return [ val ];
|
||||
array_push(arr, val);
|
||||
return arr;
|
||||
}
|
||||
|
||||
function array_get_decimal(arr, index, color = false) {
|
||||
INLINE
|
||||
|
||||
|
@ -124,136 +137,9 @@ function array_get_decimal(arr, index, color = false) {
|
|||
lerp(v0, v1, frac(index));
|
||||
}
|
||||
|
||||
function array_exists(arr, val) {
|
||||
function array_safe_length(arr) {
|
||||
INLINE
|
||||
self.__temp_val = val;
|
||||
|
||||
if(!is_array(arr)) return false;
|
||||
var _a = array_any(arr, function(_val, _ind) { return isEqual(_val, self.__temp_val); });
|
||||
|
||||
self.__temp_val = 0;
|
||||
return _a;
|
||||
}
|
||||
|
||||
function array_overlap(arr0, arr1) {
|
||||
INLINE
|
||||
self.__temp_arr = arr1;
|
||||
|
||||
if(!is_array(arr0)) return false;
|
||||
if(!is_array(arr1)) return false;
|
||||
|
||||
var _a = array_any(arr0, function(_val, _ind) { return array_exists(self.__temp_arr, _val); });
|
||||
|
||||
self.__temp_arr = 0;
|
||||
return _a;
|
||||
}
|
||||
|
||||
function array_empty(arr) { INLINE return is_array(arr) && array_length(arr) == 0; }
|
||||
function array_valid(arr) { INLINE return is_array(arr) && array_length(arr) > 0; }
|
||||
function array_invalid(arr) { INLINE return !is_array(arr) || array_length(arr) == 0; }
|
||||
|
||||
function array_find(arr, val) {
|
||||
INLINE
|
||||
self.__temp_val = val;
|
||||
|
||||
if(!is_array(arr)) return -1;
|
||||
var _a = array_find_index(arr, function(_val, _ind) { return isEqual(_val, self.__temp_val); });
|
||||
|
||||
self.__temp_val = 0;
|
||||
return _a;
|
||||
}
|
||||
|
||||
function array_find_string(arr, val) {
|
||||
INLINE
|
||||
self.__temp_val = string_lower(val);
|
||||
|
||||
if(!is_array(arr)) return -1;
|
||||
var _a = array_find_index(arr, function(_val, _ind) { return string_lower(_val) == self.__temp_val; });
|
||||
|
||||
self.__temp_val = 0;
|
||||
return _a;
|
||||
}
|
||||
|
||||
function array_remove(arr, val) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return;
|
||||
if(!array_exists(arr, val)) return;
|
||||
var ind = array_find(arr, val);
|
||||
array_delete(arr, ind, 1);
|
||||
}
|
||||
|
||||
function array_push_unique(arr, val) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return;
|
||||
if(array_exists(arr, val)) return;
|
||||
array_push(arr, val);
|
||||
}
|
||||
|
||||
function array_insert_unique(arr, ind, val) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return;
|
||||
if(array_exists(arr, val)) return;
|
||||
array_insert(arr, ind, val);
|
||||
}
|
||||
|
||||
function array_append(arr, arr0) {
|
||||
INLINE
|
||||
|
||||
if(is_undefined(arr0)) return arr;
|
||||
if(!is_array(arr)) return arr;
|
||||
if(!is_array(arr0)) { array_push(arr, arr0); return arr; }
|
||||
|
||||
for( var i = 0, n = array_length(arr0); i < n; i++ )
|
||||
array_push(arr, arr0[i]);
|
||||
return arr;
|
||||
}
|
||||
|
||||
function array_merge() {
|
||||
INLINE
|
||||
|
||||
var arr = [];
|
||||
for( var i = 0; i < argument_count; i++ )
|
||||
array_append(arr, argument[i]);
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function array_clone(arr, _depth = -1) {
|
||||
INLINE
|
||||
|
||||
if(_depth == 0) return arr;
|
||||
if(!is_array(arr)) return arr;
|
||||
|
||||
var _res = [];
|
||||
for( var i = 0, n = array_length(arr); i < n; i++ )
|
||||
_res[i] = array_clone(arr[i], _depth--);
|
||||
|
||||
return _res;
|
||||
}
|
||||
|
||||
function array_min(arr) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr) || array_length(arr) == 0) return 0;
|
||||
|
||||
var mn = arr[0];
|
||||
for( var i = 0, n = array_length(arr); i < n; i++ )
|
||||
mn = min(mn, arr[i]);
|
||||
return mn;
|
||||
}
|
||||
|
||||
function array_max(arr) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr) || array_length(arr) == 0) return 0;
|
||||
|
||||
var mx = arr[0];
|
||||
for( var i = 0, n = array_length(arr); i < n; i++ )
|
||||
mx = max(mx, arr[i]);
|
||||
return mx;
|
||||
return is_array(arr)? array_length(arr) : 0;
|
||||
}
|
||||
|
||||
function array_get_dimension(arr) {
|
||||
|
@ -302,58 +188,138 @@ function array_get_depth(arr) { // Read only the first member, faster
|
|||
return d;
|
||||
}
|
||||
|
||||
function array_spread(arr, _arr = [], _minDepth = 0) {
|
||||
INLINE
|
||||
function array_safe_set(arr, index, value, fill = 0) {
|
||||
if(!is_array(arr)) return arr;
|
||||
if(is_array(index)) return arr;
|
||||
|
||||
if(array_get_depth(arr) == _minDepth) {
|
||||
array_push(_arr, arr);
|
||||
return _arr;
|
||||
if(index < 0) return arr;
|
||||
if(index >= array_length(arr)) {
|
||||
var i = array_length(arr);
|
||||
for(; i <= index; i++ )
|
||||
arr[i] = fill;
|
||||
arr[index] = value;
|
||||
return arr;
|
||||
}
|
||||
|
||||
array_set(arr, index, value);
|
||||
return arr;
|
||||
}
|
||||
|
||||
function array_fill(arr, startIndex, endIndex, value = 0) {
|
||||
INLINE
|
||||
|
||||
for( var i = max(0, startIndex); i < endIndex; i++ )
|
||||
arr[i] = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region find
|
||||
|
||||
function array_exists(arr, val) {
|
||||
INLINE
|
||||
self.__temp_val = val;
|
||||
|
||||
if(!is_array(arr)) return false;
|
||||
var _a = array_any(arr, function(_val, _ind) { return isEqual(_val, self.__temp_val); });
|
||||
|
||||
self.__temp_val = 0;
|
||||
return _a;
|
||||
}
|
||||
|
||||
function array_find(arr, val) {
|
||||
INLINE
|
||||
self.__temp_val = val;
|
||||
|
||||
if(!is_array(arr)) return -1;
|
||||
var _a = array_find_index(arr, function(_val, _ind) { return isEqual(_val, self.__temp_val); });
|
||||
|
||||
self.__temp_val = 0;
|
||||
return _a;
|
||||
}
|
||||
|
||||
function array_find_string(arr, val) {
|
||||
INLINE
|
||||
self.__temp_val = string_lower(val);
|
||||
|
||||
if(!is_array(arr)) return -1;
|
||||
var _a = array_find_index(arr, function(_val, _ind) { return string_lower(_val) == self.__temp_val; });
|
||||
|
||||
self.__temp_val = 0;
|
||||
return _a;
|
||||
}
|
||||
|
||||
function array_min(arr) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr) || array_length(arr) == 0) return 0;
|
||||
|
||||
var mn = arr[0];
|
||||
for( var i = 0, n = array_length(arr); i < n; i++ )
|
||||
array_spread(arr[i], _arr, _minDepth);
|
||||
|
||||
return _arr;
|
||||
mn = min(mn, arr[i]);
|
||||
return mn;
|
||||
}
|
||||
|
||||
function array_verify_new(arr, length) {
|
||||
function array_max(arr) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return array_create(length);
|
||||
if(array_length(arr) == length) return arr;
|
||||
if(!is_array(arr) || array_length(arr) == 0) return 0;
|
||||
|
||||
arr = array_clone(arr, 1);
|
||||
array_resize(arr, length);
|
||||
var mx = arr[0];
|
||||
for( var i = 0, n = array_length(arr); i < n; i++ )
|
||||
mx = max(mx, arr[i]);
|
||||
return mx;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region modify
|
||||
|
||||
function array_resize_fill(arr, size, fill = 0) {
|
||||
if(size < array_length(arr)) {
|
||||
array_resize(arr, size);
|
||||
return arr;
|
||||
}
|
||||
|
||||
function array_verify(arr, length) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return array_create(length);
|
||||
if(array_length(arr) == length) return arr;
|
||||
|
||||
array_resize(arr, length);
|
||||
var i = array_length(arr);
|
||||
for(; i < size; i++)
|
||||
arr[i] = fill;
|
||||
return arr;
|
||||
}
|
||||
|
||||
function array_verify_ext(arr, length, generator) {
|
||||
function array_push_create(arr, val) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return array_create_ext(length, generator);
|
||||
|
||||
var _len = array_length(arr);
|
||||
if(_len == length) return arr;
|
||||
|
||||
array_resize(arr, length);
|
||||
var i = _len;
|
||||
|
||||
repeat(length - _len)
|
||||
arr[i++] = generator();
|
||||
|
||||
if(!is_array(arr)) return [ val ];
|
||||
array_push(arr, val);
|
||||
return arr;
|
||||
}
|
||||
|
||||
function array_remove(arr, val) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return;
|
||||
if(!array_exists(arr, val)) return;
|
||||
var ind = array_find(arr, val);
|
||||
array_delete(arr, ind, 1);
|
||||
}
|
||||
|
||||
function array_push_unique(arr, val) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return;
|
||||
if(array_exists(arr, val)) return;
|
||||
array_push(arr, val);
|
||||
}
|
||||
|
||||
function array_insert_unique(arr, ind, val) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(arr)) return;
|
||||
if(array_exists(arr, val)) return;
|
||||
array_insert(arr, ind, val);
|
||||
}
|
||||
|
||||
function array_insert_after(arr, before, values) {
|
||||
INLINE
|
||||
|
||||
|
@ -379,6 +345,58 @@ function array_push_to_back(arr, value) {
|
|||
array_push(arr, value);
|
||||
}
|
||||
|
||||
function array_spread(arr, _arr = [], _minDepth = 0) {
|
||||
INLINE
|
||||
|
||||
if(array_get_depth(arr) == _minDepth) {
|
||||
array_push(_arr, arr);
|
||||
return _arr;
|
||||
}
|
||||
|
||||
for( var i = 0, n = array_length(arr); i < n; i++ )
|
||||
array_spread(arr[i], _arr, _minDepth);
|
||||
|
||||
return _arr;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region binary opr
|
||||
|
||||
function array_overlap(arr0, arr1) {
|
||||
INLINE
|
||||
self.__temp_arr = arr1;
|
||||
|
||||
if(!is_array(arr0)) return false;
|
||||
if(!is_array(arr1)) return false;
|
||||
|
||||
var _a = array_any(arr0, function(_val, _ind) { return array_exists(self.__temp_arr, _val); });
|
||||
|
||||
self.__temp_arr = 0;
|
||||
return _a;
|
||||
}
|
||||
|
||||
function array_append(arr, arr0) {
|
||||
INLINE
|
||||
|
||||
if(is_undefined(arr0)) return arr;
|
||||
if(!is_array(arr)) return arr;
|
||||
if(!is_array(arr0)) { array_push(arr, arr0); return arr; }
|
||||
|
||||
for( var i = 0, n = array_length(arr0); i < n; i++ )
|
||||
array_push(arr, arr0[i]);
|
||||
return arr;
|
||||
}
|
||||
|
||||
function array_merge() {
|
||||
INLINE
|
||||
|
||||
var arr = [];
|
||||
for( var i = 0; i < argument_count; i++ )
|
||||
array_append(arr, argument[i]);
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
#macro array_equals array_equals_overwrite
|
||||
#macro __array_equals array_equals
|
||||
|
||||
|
@ -388,3 +406,28 @@ function array_equals_overwrite(arr1, arr2) {
|
|||
if(!is_array(arr1) && !is_array(arr2)) return arr1 == arr2;
|
||||
return __array_equals(arr1, arr2)
|
||||
}
|
||||
|
||||
function array_substract(arr1, arr2) {
|
||||
if(!is_array(arr1) || !is_array(arr2)) return;
|
||||
|
||||
var _hsh = {};
|
||||
var _arr = [];
|
||||
|
||||
for( var i = 0, n = array_length(arr2); i < n; i++ )
|
||||
_hsh[$ arr2[i]] = (_hsh[$ arr2[i]] ?? 0) + 1;
|
||||
|
||||
for( var i = 0, n = array_length(arr1); i < n; i++ ) {
|
||||
if(!struct_has(_hsh, arr1[i]) || _hsh[$ arr1[i]]-- <= 0)
|
||||
array_push(_arr, arr1[i]);
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function array_xor(arr1, arr2) {
|
||||
if(!is_array(arr1) || !is_array(arr2)) return;
|
||||
|
||||
var _arr = array_union(array_substract(arr1, arr2), array_substract(arr2, arr1));
|
||||
return _arr;
|
||||
}
|
||||
#endregion
|
||||
|
|
62
scripts/node_array_boolean_opr/node_array_boolean_opr.gml
Normal file
62
scripts/node_array_boolean_opr/node_array_boolean_opr.gml
Normal file
|
@ -0,0 +1,62 @@
|
|||
function Node_Array_Boolean_Opr(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Array Boolean Opr";
|
||||
setDimension(96, 32 + 24);
|
||||
|
||||
newInput(0, nodeValue("Array 1", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
|
||||
.setVisible(true, true);
|
||||
|
||||
newInput(1, nodeValue("Array 2", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0))
|
||||
.setVisible(true, true);
|
||||
|
||||
newInput(2, nodeValue_Enum_Scroll("Operation", self, 0, [ "Union", "Subtract", "Intersect", "XOR" ]))
|
||||
.setVisible(true, true);
|
||||
|
||||
newOutput(0, nodeValue_Output("Array out", self, VALUE_TYPE.any, []));
|
||||
|
||||
input_display_list = [ 2, 0, 1 ];
|
||||
|
||||
static update = function(frame = CURRENT_FRAME) {
|
||||
var arr1 = getInputData(0);
|
||||
var arr2 = getInputData(1);
|
||||
var opr = getInputData(2);
|
||||
|
||||
inputs[0].setType(VALUE_TYPE.any);
|
||||
inputs[1].setType(VALUE_TYPE.any);
|
||||
outputs[0].setType(VALUE_TYPE.any);
|
||||
|
||||
if(inputs[0].value_from != noone) {
|
||||
inputs[0].setType(inputs[0].value_from.type);
|
||||
inputs[1].setType(inputs[1].value_from.type);
|
||||
outputs[0].setType(inputs[0].value_from.type);
|
||||
}
|
||||
|
||||
if(!is_array(arr1) || !is_array(arr2)) return;
|
||||
|
||||
var _arr;
|
||||
|
||||
switch(opr) {
|
||||
case 0 : _arr = array_union(arr1, arr2); break;
|
||||
case 1 : _arr = array_substract(arr1, arr2); break;
|
||||
case 2 : _arr = array_intersection(arr1, arr2); break;
|
||||
case 3 : _arr = array_xor(arr1, arr2); break;
|
||||
}
|
||||
|
||||
outputs[0].setValue(_arr);
|
||||
}
|
||||
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||
var bbox = drawGetBbox(xx, yy, _s);
|
||||
var opr = getInputData(2);
|
||||
var str = "";
|
||||
|
||||
switch(opr) {
|
||||
case 0 : str = "union" break;
|
||||
case 1 : str = "substract" break;
|
||||
case 2 : str = "intersection" break;
|
||||
case 3 : str = "xor" break;
|
||||
}
|
||||
|
||||
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
||||
draw_text_bbox(bbox, str);
|
||||
}
|
||||
}
|
14
scripts/node_array_boolean_opr/node_array_boolean_opr.yy
Normal file
14
scripts/node_array_boolean_opr/node_array_boolean_opr.yy
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"$GMScript":"v1",
|
||||
"%Name":"node_array_boolean_opr",
|
||||
"isCompatibility":false,
|
||||
"isDnD":false,
|
||||
"name":"node_array_boolean_opr",
|
||||
"parent":{
|
||||
"name":"array",
|
||||
"path":"folders/nodes/data/value/array.yy",
|
||||
},
|
||||
"resourceType":"GMScript",
|
||||
"resourceVersion":"2.0",
|
||||
"tags":[],
|
||||
}
|
|
@ -19,7 +19,7 @@ function __NodeValue_Float(_name, _node, _value, _tooltip = "") : NodeValue(_nam
|
|||
|
||||
if(typ != VALUE_TYPE.surface) {
|
||||
if(typ == VALUE_TYPE.text) val = toNumber(val);
|
||||
if(struct_has(val, "to_real")) val = val.to_real();
|
||||
if(is_struct(val) && struct_has(val, "to_real")) val = val.to_real();
|
||||
|
||||
return valueProcess(val, nod, applyUnit);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ function __NodeValue_Int(_name, _node, _value, _tooltip = "") : NodeValue(_name,
|
|||
|
||||
if(typ != VALUE_TYPE.surface) {
|
||||
if(typ == VALUE_TYPE.text) val = toNumber(val);
|
||||
if(struct_has(val, "to_real")) val = val.to_real();
|
||||
if(is_struct(val) && struct_has(val, "to_real")) val = val.to_real();
|
||||
|
||||
return valueProcess(val, nod, applyUnit);
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
90
sprites/s_node_array_boolean_opr/s_node_array_boolean_opr.yy
Normal file
90
sprites/s_node_array_boolean_opr/s_node_array_boolean_opr.yy
Normal file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"$GMSprite":"",
|
||||
"%Name":"s_node_array_boolean_opr",
|
||||
"bboxMode":0,
|
||||
"bbox_bottom":63,
|
||||
"bbox_left":0,
|
||||
"bbox_right":63,
|
||||
"bbox_top":0,
|
||||
"collisionKind":1,
|
||||
"collisionTolerance":0,
|
||||
"DynamicTexturePage":false,
|
||||
"edgeFiltering":false,
|
||||
"For3D":false,
|
||||
"frames":[
|
||||
{"$GMSpriteFrame":"","%Name":"3f6813f5-0553-4de8-96d6-c7d745fffe40","name":"3f6813f5-0553-4de8-96d6-c7d745fffe40","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
],
|
||||
"gridX":0,
|
||||
"gridY":0,
|
||||
"height":64,
|
||||
"HTile":false,
|
||||
"layers":[
|
||||
{"$GMImageLayer":"","%Name":"8b6cb694-da18-4679-b77a-1770cc5ebe4f","blendMode":0,"displayName":"default","isLocked":false,"name":"8b6cb694-da18-4679-b77a-1770cc5ebe4f","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
|
||||
],
|
||||
"name":"s_node_array_boolean_opr",
|
||||
"nineSlice":null,
|
||||
"origin":4,
|
||||
"parent":{
|
||||
"name":"array",
|
||||
"path":"folders/nodes/icons/value/array.yy",
|
||||
},
|
||||
"preMultiplyAlpha":false,
|
||||
"resourceType":"GMSprite",
|
||||
"resourceVersion":"2.0",
|
||||
"sequence":{
|
||||
"$GMSequence":"",
|
||||
"%Name":"s_node_array_boolean_opr",
|
||||
"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_array_boolean_opr",
|
||||
"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":"3f6813f5-0553-4de8-96d6-c7d745fffe40","path":"sprites/s_node_array_boolean_opr/s_node_array_boolean_opr.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"dd4a2d62-327f-4cc6-856a-909eead3e7d3","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