This commit is contained in:
Tanasart 2024-08-19 11:16:12 +07:00
parent 37755e8c23
commit 2e685d9016
11 changed files with 93 additions and 102 deletions

View file

@ -2,8 +2,8 @@
"$GMObject":"",
"%Name":"Obj_FirebaseFirestore_Document_Set",
"eventList":[
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":7,"eventType":6,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":7,"eventType":6,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
],
"managed":true,
"name":"Obj_FirebaseFirestore_Document_Set",

View file

@ -2,10 +2,10 @@
"$GMObject":"",
"%Name":"o_dialog_menubox",
"eventList":[
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":1,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":1,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
],
"managed":true,
"name":"o_dialog_menubox",

View file

@ -55,8 +55,9 @@
#region Set up
var t = current_time;
if(!IS_CMD) { __initHotKey(); log_message("SESSION", $"> init Hotkeys | complete in {get_timer() - t}"); t = get_timer(); }
PREF_LOAD(); log_message("SESSION", $"> init Preferences | complete in {get_timer() - t}"); t = get_timer();
if(!IS_CMD) { __initHotKey(); log_message("SESSION", $"> init Hotkeys | complete in {get_timer() - t}"); t = get_timer(); }
__fnInit();
var dir = string(DIRECTORY) + "log";
directory_verify(dir);

View file

@ -61,10 +61,10 @@ function fileNameCall(path, onModify, _x = mouse_mx + 8, _y = mouse_my + 8) {
return dia;
}
function menuItem( name, func, spr = noone, hotkey = noone, toggle = noone, params = {}) { return new MenuItem(name, func, spr, hotkey, toggle, params); }
function menuItemShelf(name, func, spr = noone, hotkey = noone, toggle = noone, params = {}) { return new MenuItem(name, func, spr, hotkey, toggle, params).setIsShelf(); }
function menuItem( name, func, spr = noone, hotkey = noone, toggle = noone, params = noone) { return new MenuItem(name, func, spr, hotkey, toggle, params); }
function menuItemShelf(name, func, spr = noone, hotkey = noone, toggle = noone, params = noone) { return new MenuItem(name, func, spr, hotkey, toggle, params).setIsShelf(); }
function MenuItem(_name, _func, _spr = noone, _hotkey = noone, _toggle = noone, _params = {}) constructor {
function MenuItem(_name, _func, _spr = noone, _hotkey = noone, _toggle = noone, _params = noone) constructor {
active = true;
name = _name;
func = _func;

View file

@ -1,5 +1,5 @@
#region macros
gml_pragma("global", "__fnInit()");
// gml_pragma("global", "__fnInit()");
#macro ARG new __fnArgument
#macro CALL _args = []; for(i = 0; i < argument_count; i++) _args[i] = argument[i]; callStatusFunction
@ -10,9 +10,10 @@
self.fn = fn;
}
function __fnInit() {
globalvar CMD_FUNCTIONS, MENU_ITEMS, FUNCTIONS, RECENT_COMMANDS;
function __fnInit() {
FUNCTIONS = {};
CMD_FUNCTIONS = {};
MENU_ITEMS = {};

View file

@ -37,10 +37,10 @@
globalvar HOTKEYS, HOTKEY_CONTEXT;
LATEST_VERSION = 1_16_00_0;
VERSION = 1_17_10_2;
VERSION = 1_17_10_3;
SAVE_VERSION = 1_17_10_0;
VERSION_STRING = "1.17.10.2";
BUILD_NUMBER = 1_17_10_2;
VERSION_STRING = "1.17.10.3";
BUILD_NUMBER = 1_17_10_3;
HOTKEYS = ds_map_create();
HOTKEY_CONTEXT = ds_list_create();

View file

@ -236,7 +236,6 @@ function hotkey_draw(keyStr, _x, _y, _status = 0) {
}
function hotkey_serialize() {
var _context = [];
for(var i = 0, n = ds_list_size(HOTKEY_CONTEXT); i < n; i++) {
var ll = HOTKEYS[? HOTKEY_CONTEXT[| i]];

View file

@ -32,7 +32,7 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
attribute_surface_depth();
function sortPalette(pal) { #region
function sortPalette(pal) {
array_sort(pal, function(c0, c1) {
var r0 = _color_get_red(c0);
var r1 = _color_get_red(c1);
@ -59,9 +59,9 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
return s0 * v0 > s1 * v1;
})
} #endregion
}
function extractKmean(_surfFull, _size, _seed) { #region
function extractKmean(_surfFull, _size, _seed) {
var _space = getInputData(4);
var _surf = surface_create_valid(min(32, surface_get_width_safe(_surfFull)), min(32, surface_get_height_safe(_surfFull)), attrDepth());
_size = max(1, _size);
@ -96,26 +96,19 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
}
array_push(colors, col);
for( var j = 0; j < 3; j++ ) {
_min[j] = min(_min[j], col[j]);
_max[j] = max(_max[j], col[j]);
}
_min[0] = min(_min[0], col[0]); _max[0] = max(_max[0], col[0]);
_min[1] = min(_min[1], col[1]); _max[1] = max(_max[1], col[1]);
_min[2] = min(_min[2], col[2]); _max[2] = max(_max[2], col[2]);
}
buffer_delete(c_buffer);
var cnt = [];
random_set_seed(_seed);
for( var i = 0; i < _size; i++ )
cnt[i] = [ random(1), random(1), random(1), 0 ];
cnt = array_create_ext(_size, function() /*=>*/ {return [ random(1), random(1), random(1), 0 ]});
repeat(8) {
var _cnt = [];
for( var i = 0; i < _size; i++ ) {
_cnt[i][0] = cnt[i][0];
_cnt[i][1] = cnt[i][1];
_cnt[i][2] = cnt[i][2];
}
// var _cnt = array_create_ext(_size, (i) => [ cnt[i][0], cnt[i][1], cnt[i][2], 0 ]);
for( var i = 0, n = array_length(colors); i < n; i++ ) {
var ind = 0;
@ -125,6 +118,7 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
for( var j = 0; j < _size; j++ ) {
var _cn = cnt[j];
var d = point_distance_3d(_cl[0], _cl[1], _cl[2], _cn[0], _cn[1], _cn[2]);
if(d < dist) {
dist = d;
ind = j;
@ -139,24 +133,23 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
for( var i = 0, n = array_length(colors); i < n; i++ ) {
var _cl = colors[i];
cnt[_cl[3]][0] += _cl[0];
cnt[_cl[3]][1] += _cl[1];
cnt[_cl[3]][2] += _cl[2];
cnt[_cl[3]][3]++;
var _co = _cl[3];
cnt[_co][0] += _cl[0];
cnt[_co][1] += _cl[1];
cnt[_co][2] += _cl[2];
cnt[_co][3]++;
}
for( var i = 0; i < _size; i++ ) {
cnt[i][0] = cnt[i][3]? cnt[i][0] / cnt[i][3] : 0;
cnt[i][1] = cnt[i][3]? cnt[i][1] / cnt[i][3] : 0;
cnt[i][2] = cnt[i][3]? cnt[i][2] / cnt[i][3] : 0;
var _cc = cnt[i];
cnt[i][0] = _cc[3]? _cc[0] / _cc[3] : 0;
cnt[i][1] = _cc[3]? _cc[1] / _cc[3] : 0;
cnt[i][2] = _cc[3]? _cc[2] / _cc[3] : 0;
}
var del = 0;
for( var i = 0; i < _size; i++ ) {
del = max(del, point_distance_3d(cnt[i][0], cnt[i][1], cnt[i][2], _cnt[i][0], _cnt[i][1], _cnt[i][2]));
}
if(del < 0.001) break;
// var del = array_reduce(cnt, (prev, cur, i) => max(prev, point_distance_3d(cnt[i][0], cnt[i][1], cnt[i][2], cur[0], cur[1], cur[2])), 0);
// if(del < 0.001) break;
}
var palette = [];
@ -167,7 +160,7 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
var dist = 999;
var _cl = cnt[i];
for( var j = 0; j < array_length(colors); j++ ) {
for( var j = 0, n = array_length(colors); j < n; j++ ) {
var _cn = colors[j];
var d = point_distance_3d(_cl[0], _cl[1], _cl[2], _cn[0], _cn[1], _cn[2]);
@ -177,10 +170,12 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
}
}
var _cc = colors[closet];
switch(_space) {
case 0 : clr = make_color_rgb(colors[closet][0] * 255, colors[closet][1] * 255, colors[closet][2] * 255); break;
case 1 : clr = make_color_hsv(colors[closet][0] * 255, colors[closet][1] * 255, colors[closet][2] * 255); break;
case 2 : clr = make_color_hsv(colors[closet][0] * 255, colors[closet][1] * 255, colors[closet][2] * 255); break;
case 0 : clr = make_color_rgba(_cc[0] * 255, _cc[1] * 255, _cc[2] * 255, 255); break;
case 1 : clr = make_color_hsva(_cc[0] * 255, _cc[1] * 255, _cc[2] * 255, 255); break;
case 2 : clr = make_color_hsva(_cc[0] * 255, _cc[1] * 255, _cc[2] * 255, 255); break;
}
array_push_unique(palette, clr);
@ -190,9 +185,9 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
sortPalette(palette);
return palette;
} #endregion
}
function extractAll(_surfFull) { #region
function extractAll(_surfFull) {
var ww = surface_get_width_safe(_surfFull);
var hh = surface_get_height_safe(_surfFull);
@ -205,19 +200,20 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
for( var i = 0; i < ww * hh; i++ ) {
var b = buffer_read(c_buffer, buffer_u32);
var c = b & ~(0b11111111 << 24);
var c = b;
var a = b & (0b11111111 << 24);
if(a == 0) continue;
c = make_color_rgb(color_get_red(c), color_get_green(c), color_get_blue(c));
c = make_color_rgba(color_get_red(c), color_get_green(c), color_get_blue(c), color_get_alpha(c));
if(!array_exists(palette, c))
array_push(palette, c);
}
buffer_delete(c_buffer);
return palette;
} #endregion
}
function extractFrequence(_surfFull, _size) { #region
function extractFrequence(_surfFull, _size) {
var msize = 128;
var _surf = surface_create_valid(min(msize, surface_get_width_safe(_surfFull)), min(msize, surface_get_height_safe(_surfFull)));
_size = max(1, _size);
@ -227,9 +223,9 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
surface_set_target(_surf);
DRAW_CLEAR
BLEND_OVERRIDE;
BLEND_OVERRIDE
draw_surface_stretched_safe(_surfFull, 0, 0, ww, hh);
BLEND_NORMAL;
BLEND_NORMAL
surface_reset_target();
var c_buffer = buffer_create(ww * hh * 4, buffer_fixed, 2);
@ -238,51 +234,49 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
buffer_get_surface(c_buffer, _surf, 0);
buffer_seek(c_buffer, buffer_seek_start, 0);
var palette = [];
var clrs = ds_map_create();
for( var i = 0; i < ww * hh; i++ ) {
var b = buffer_read(c_buffer, buffer_u32);
var c = b & ~(0b11111111 << 24);
var a = b & (0b11111111 << 24);
var c = b;
var a = b & (0b_1111_1111 << 24) >> 24;
if(a == 0) continue;
c = make_color_rgb(color_get_red(c), color_get_green(c), color_get_blue(c));
if(ds_map_exists(clrs, c))
clrs[? c]++;
else
clrs[? c] = 0;
c = make_color_rgba(color_get_red(c), color_get_green(c), color_get_blue(c), color_get_alpha(c));
if(ds_map_exists(clrs, c)) clrs[? c].amount++;
else clrs[? c] = { color: c, amount: 1 };
}
buffer_delete(c_buffer);
var pr = ds_priority_create();
var amo = ds_map_size(clrs);
var k = ds_map_find_first(clrs);
var amo = ds_map_size(clrs);
repeat(amo) {
ds_priority_add(pr, k, clrs[? k]);
ds_priority_add(pr, clrs[? k].color, clrs[? k].amount);
k = ds_map_find_next(clrs, k);
}
for( var i = 0; i < _size; i++ ) {
if(ds_priority_empty(pr)) break;
array_push(palette, ds_priority_delete_max(pr));
}
var amo = min(_size, ds_priority_size(pr));
var pal = array_create(amo), ind = 0;
repeat(amo) { pal[ind++] = ds_priority_delete_max(pr); }
ds_priority_destroy(pr);
ds_map_destroy(clrs);
return palette;
} #endregion
static step = function() { #region
return pal;
}
static step = function() {
var _algo = getInputData(3);
inputs[1].setVisible(_algo != 2);
inputs[2].setVisible(_algo == 0);
inputs[4].setVisible(_algo == 0);
} #endregion
}
static extractPalette = function(_surf, _algo, _size, _seed) { #region
static extractPalette = function(_surf, _algo, _size, _seed) {
if(!is_surface(_surf)) return [];
switch(_algo) {
@ -292,18 +286,18 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
}
return [];
} #endregion
}
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _surf = _data[0];
var _size = _data[1];
var _seed = _data[2];
var _algo = _data[3];
return extractPalette(_surf, _algo, _size, _seed);
} #endregion
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s);
if(bbox.h < 1) return;
@ -322,5 +316,5 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
if(_h != min_h) will_setHeight = true;
min_h = _h;
} #endregion
}
}

View file

@ -624,7 +624,7 @@ function __initNodes() {
addNodeObject(filter, "Local Analyze", s_node_local_analyze, "Node_Local_Analyze", [1, Node_Local_Analyze],, "Apply non-linear operation (minimum, maximum) on each pixel locally.").setVersion(1110);
addNodeObject(filter, "SDF", s_node_sdf, "Node_SDF", [1, Node_SDF],, "Create signed distance field using jump flooding algorithm.").setVersion(1130);
addNodeObject(filter, "Replace Image", s_node_image_replace, "Node_Surface_Replace", [1, Node_Surface_Replace], ["image replace"], "Replace instances of an image with a new one.").setVersion(1140);
addNodeObject(filter, "Chromatic Aberration", s_node_chromatic_abarration, "Node_Chromatic_Aberration", [1, Node_Chromatic_Aberration],, "Apply chromatic aberration effect to the image.");
addNodeObject(filter, "Chromatic Aberration",s_node_chromatic_abarration, "Node_Chromatic_Aberration", [1, Node_Chromatic_Aberration],, "Apply chromatic aberration effect to the image.");
addNodeObject(filter, "Vignette", s_node_vignette, "Node_Vignette", [1, Node_Vignette],, "Apply vignette effect to the border.").setVersion(11630);
addNodeObject(filter, "FXAA", s_node_FXAA, "Node_FXAA", [1, Node_FXAA],, "Apply fast approximate anti-aliasing to te image.");
addNodeObject(filter, "JPEG", s_node_JPEG, "Node_JPEG", [1, Node_JPEG],, "Apply JPEG compression to the image.").setVersion(11730);

View file

@ -1359,8 +1359,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static unitConvert = function(mode) {
var _v = animator.values;
for( var i = 0; i < ds_list_size(_v); i++ )
_v[| i].value = unit.convertUnit(_v[| i].value, mode);
for( var i = 0; i < array_length(_v); i++ )
_v[i].value = unit.convertUnit(_v[i].value, mode);
}
static isDynamicArray = function() {

View file

@ -252,7 +252,6 @@
json_save_struct(DIRECTORY + "keys.json", PREFERENCES);
json_save_struct(DIRECTORY + "Nodes/fav.json", global.FAV_NODES);
json_save_struct(DIRECTORY + "Nodes/recent.json", global.RECENT_NODES);
json_save_struct(DIRECTORY + "key_nodes.json", HOTKEYS_CUSTOM);
json_save_struct(DIRECTORY + "default_project.json", PROJECT_ATTRIBUTES);
hotkey_serialize();
@ -269,9 +268,6 @@
if(!directory_exists($"{DIRECTORY}Themes/{PREFERENCES.theme}"))
PREFERENCES.theme = "default";
var f = json_load_struct(DIRECTORY + "key_nodes.json");
struct_override_nested(HOTKEYS_CUSTOM, f);
LOCALE_DEF = PREFERENCES.local == "en";
THEME_DEF = PREFERENCES.theme == "default";
FONT_DEF = PREFERENCES.theme == "default" && PREFERENCES.local == "en" && PREFERENCES.display_scaling == 1;