From 953633792c681b2f51ed801abcddfb05cbab17a3 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Wed, 22 May 2024 09:46:29 +0700 Subject: [PATCH] Connection transfer --- PixelComposer.resource_order | 5 +- PixelComposer.yyp | 6 +- .../contextMenu_controller.gml | 8 + scripts/directory_object/directory_object.gml | 9 +- scripts/node_registry/node_registry.gml | 4 +- scripts/node_value/node_value.gml | 4 +- scripts/panel_collection/panel_collection.gml | 21 +- scripts/panel_color/panel_color.gml | 191 ++++++++++++------ scripts/panel_data/panel_data.gml | 9 +- .../panel_file_explorer.gml | 26 ++- scripts/panel_function/panel_function.gml | 2 + scripts/panel_graph/panel_graph.gml | 56 +++-- scripts/panel_menu/panel_menu.gml | 2 + scripts/panel_palette/panel_palette.gml | 33 ++- .../panel_palette_mixer.gml | 36 +++- .../panel_preview_histogram.gml | 52 +++++ .../panel_preview_histogram.yy | 13 ++ .../sh_color_picker_side_hue.fsh | 6 +- .../sh_color_select_content.fsh | 35 +++- .../sh_color_select_side.fsh | 37 +++- .../sh_preview_histogram.fsh | 42 ++++ .../sh_preview_histogram.vsh | 19 ++ .../sh_preview_histogram.yy | 12 ++ .../sh_preview_histogram_outline.fsh | 18 ++ .../sh_preview_histogram_outline.vsh | 19 ++ .../sh_preview_histogram_outline.yy | 12 ++ 26 files changed, 542 insertions(+), 135 deletions(-) create mode 100644 scripts/panel_preview_histogram/panel_preview_histogram.gml create mode 100644 scripts/panel_preview_histogram/panel_preview_histogram.yy create mode 100644 shaders/sh_preview_histogram/sh_preview_histogram.fsh create mode 100644 shaders/sh_preview_histogram/sh_preview_histogram.vsh create mode 100644 shaders/sh_preview_histogram/sh_preview_histogram.yy create mode 100644 shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.fsh create mode 100644 shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.vsh create mode 100644 shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.yy diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index d35f65145..fe216de21 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -157,6 +157,7 @@ {"name":"find_boundary","order":7,"path":"folders/shader/misc/find_boundary.yy",}, {"name":"Flag","order":3,"path":"folders/shader/MK effects/Flag.yy",}, {"name":"Tile","order":4,"path":"folders/shader/MK effects/Tile.yy",}, + {"name":"histogram","order":4,"path":"folders/shader/UI/histogram.yy",}, {"name":"palette mixer","order":2,"path":"folders/shader/UI/palette mixer.yy",}, ], "ResourceOrderSettings":[ @@ -1111,6 +1112,7 @@ {"name":"panel_patreon","order":2,"path":"scripts/panel_patreon/panel_patreon.yy",}, {"name":"panel_preview_3d_setting","order":2,"path":"scripts/panel_preview_3d_setting/panel_preview_3d_setting.yy",}, {"name":"panel_preview_grid_setting","order":4,"path":"scripts/panel_preview_grid_setting/panel_preview_grid_setting.yy",}, + {"name":"panel_preview_histogram","order":8,"path":"scripts/panel_preview_histogram/panel_preview_histogram.yy",}, {"name":"panel_preview_onion_setting","order":5,"path":"scripts/panel_preview_onion_setting/panel_preview_onion_setting.yy",}, {"name":"panel_preview_snap_setting","order":3,"path":"scripts/panel_preview_snap_setting/panel_preview_snap_setting.yy",}, {"name":"panel_preview_window","order":1,"path":"scripts/panel_preview_window/panel_preview_window.yy",}, @@ -1422,6 +1424,7 @@ {"name":"sh_override_channel","order":21,"path":"shaders/sh_override_channel/sh_override_channel.yy",}, {"name":"sh_palette_mixer_atlas_expand_apply","order":2,"path":"shaders/sh_palette_mixer_atlas_expand_apply/sh_palette_mixer_atlas_expand_apply.yy",}, {"name":"sh_palette_mixer_atlas_expand_iterate","order":1,"path":"shaders/sh_palette_mixer_atlas_expand_iterate/sh_palette_mixer_atlas_expand_iterate.yy",}, + {"name":"sh_palette_mixer_atlas_expand_palette","order":3,"path":"shaders/sh_palette_mixer_atlas_expand_palette/sh_palette_mixer_atlas_expand_palette.yy",}, {"name":"sh_palette_replace","order":24,"path":"shaders/sh_palette_replace/sh_palette_replace.yy",}, {"name":"sh_palette_shift","order":19,"path":"shaders/sh_palette_shift/sh_palette_shift.yy",}, {"name":"sh_path_fill_profile","order":15,"path":"shaders/sh_path_fill_profile/sh_path_fill_profile.yy",}, @@ -1506,7 +1509,7 @@ {"name":"sh_widget_rotator_range","order":5,"path":"shaders/sh_widget_rotator_range/sh_widget_rotator_range.yy",}, {"name":"sh_widget_rotator","order":4,"path":"shaders/sh_widget_rotator/sh_widget_rotator.yy",}, {"name":"sh_zigzag","order":2,"path":"shaders/sh_zigzag/sh_zigzag.yy",}, - {"name":"sh_palette_mixer_atlas_expand_palette","order":3,"path":"shaders/sh_palette_mixer_atlas_expand_palette/sh_palette_mixer_atlas_expand_palette.yy",}, + {"name":"sh_preview_histogram_outline","order":1,"path":"shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.yy",}, {"name":"credit_badge_popular","order":2,"path":"sprites/credit_badge_popular/credit_badge_popular.yy",}, {"name":"credit_badge_value","order":1,"path":"sprites/credit_badge_value/credit_badge_value.yy",}, {"name":"s_biterator_b_grey_long","order":7,"path":"sprites/s_biterator_b_grey_long/s_biterator_b_grey_long.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index e1cecb90a..2da516ba5 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -295,6 +295,7 @@ {"$GMFolder":"","%Name":"sprites","folderPath":"folders/shader/sprites.yy","name":"sprites","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"transition","folderPath":"folders/shader/transition.yy","name":"transition","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"UI","folderPath":"folders/shader/UI.yy","name":"UI","resourceType":"GMFolder","resourceVersion":"2.0",}, + {"$GMFolder":"","%Name":"histogram","folderPath":"folders/shader/UI/histogram.yy","name":"histogram","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"palette mixer","folderPath":"folders/shader/UI/palette mixer.yy","name":"palette mixer","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"sprites","folderPath":"folders/sprites.yy","name":"sprites","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"bs","folderPath":"folders/sprites/bs.yy","name":"bs","resourceType":"GMFolder","resourceVersion":"2.0",}, @@ -1580,6 +1581,7 @@ {"id":{"name":"panel_patreon","path":"scripts/panel_patreon/panel_patreon.yy",},}, {"id":{"name":"panel_preview_3d_setting","path":"scripts/panel_preview_3d_setting/panel_preview_3d_setting.yy",},}, {"id":{"name":"panel_preview_grid_setting","path":"scripts/panel_preview_grid_setting/panel_preview_grid_setting.yy",},}, + {"id":{"name":"panel_preview_histogram","path":"scripts/panel_preview_histogram/panel_preview_histogram.yy",},}, {"id":{"name":"panel_preview_onion_setting","path":"scripts/panel_preview_onion_setting/panel_preview_onion_setting.yy",},}, {"id":{"name":"panel_preview_snap_setting","path":"scripts/panel_preview_snap_setting/panel_preview_snap_setting.yy",},}, {"id":{"name":"panel_preview_window","path":"scripts/panel_preview_window/panel_preview_window.yy",},}, @@ -1948,6 +1950,7 @@ {"id":{"name":"sh_palette_mixer_atlas_expand_apply","path":"shaders/sh_palette_mixer_atlas_expand_apply/sh_palette_mixer_atlas_expand_apply.yy",},}, {"id":{"name":"sh_palette_mixer_atlas_expand_coord","path":"shaders/sh_palette_mixer_atlas_expand_coord/sh_palette_mixer_atlas_expand_coord.yy",},}, {"id":{"name":"sh_palette_mixer_atlas_expand_iterate","path":"shaders/sh_palette_mixer_atlas_expand_iterate/sh_palette_mixer_atlas_expand_iterate.yy",},}, + {"id":{"name":"sh_palette_mixer_atlas_expand_palette","path":"shaders/sh_palette_mixer_atlas_expand_palette/sh_palette_mixer_atlas_expand_palette.yy",},}, {"id":{"name":"sh_palette_replace","path":"shaders/sh_palette_replace/sh_palette_replace.yy",},}, {"id":{"name":"sh_palette_shift","path":"shaders/sh_palette_shift/sh_palette_shift.yy",},}, {"id":{"name":"sh_path_fill_profile","path":"shaders/sh_path_fill_profile/sh_path_fill_profile.yy",},}, @@ -1971,6 +1974,7 @@ {"id":{"name":"sh_polar","path":"shaders/sh_polar/sh_polar.yy",},}, {"id":{"name":"sh_posterize_palette","path":"shaders/sh_posterize_palette/sh_posterize_palette.yy",},}, {"id":{"name":"sh_posterize","path":"shaders/sh_posterize/sh_posterize.yy",},}, + {"id":{"name":"sh_preview_histogram","path":"shaders/sh_preview_histogram/sh_preview_histogram.yy",},}, {"id":{"name":"sh_pytagorean_tile","path":"shaders/sh_pytagorean_tile/sh_pytagorean_tile.yy",},}, {"id":{"name":"sh_quarsicrystal","path":"shaders/sh_quarsicrystal/sh_quarsicrystal.yy",},}, {"id":{"name":"sh_random_tile","path":"shaders/sh_random_tile/sh_random_tile.yy",},}, @@ -2045,7 +2049,7 @@ {"id":{"name":"sh_widget_rotator_range","path":"shaders/sh_widget_rotator_range/sh_widget_rotator_range.yy",},}, {"id":{"name":"sh_widget_rotator","path":"shaders/sh_widget_rotator/sh_widget_rotator.yy",},}, {"id":{"name":"sh_zigzag","path":"shaders/sh_zigzag/sh_zigzag.yy",},}, - {"id":{"name":"sh_palette_mixer_atlas_expand_palette","path":"shaders/sh_palette_mixer_atlas_expand_palette/sh_palette_mixer_atlas_expand_palette.yy",},}, + {"id":{"name":"sh_preview_histogram_outline","path":"shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.yy",},}, {"id":{"name":"credit_badge_popular","path":"sprites/credit_badge_popular/credit_badge_popular.yy",},}, {"id":{"name":"credit_badge_value","path":"sprites/credit_badge_value/credit_badge_value.yy",},}, {"id":{"name":"node_credit","path":"sprites/node_credit/node_credit.yy",},}, diff --git a/scripts/contextMenu_controller/contextMenu_controller.gml b/scripts/contextMenu_controller/contextMenu_controller.gml index 72d6c4c13..fa0cf834f 100644 --- a/scripts/contextMenu_controller/contextMenu_controller.gml +++ b/scripts/contextMenu_controller/contextMenu_controller.gml @@ -43,6 +43,14 @@ return dia; } + function fileNameCall(path, onModify, _x = mouse_mx + 8, _y = mouse_my + 8) { + var dia = dialogCall(o_dialog_file_name, _x, _y); + dia.onModify = onModify; + dia.path = string_trim_end(path, [ "\\", "/" ]) + "/"; + + return dia; + } + function menuItem(name, func, spr = noone, hotkey = noone, toggle = noone, params = {}) { INLINE return new MenuItem(name, func, spr, hotkey, toggle, params); diff --git a/scripts/directory_object/directory_object.gml b/scripts/directory_object/directory_object.gml index ecbc63135..7eab01e05 100644 --- a/scripts/directory_object/directory_object.gml +++ b/scripts/directory_object/directory_object.gml @@ -186,11 +186,11 @@ function DirectoryObject(name, path) constructor { #region } } #endregion - static draw = function(parent, _x, _y, _m, _w, _hover, _focus, _homedir, _colors = {}) { #region + static draw = function(parent, _x, _y, _m, _w, _hover, _focus, _homedir, _params = {}) { #region var hg = ui(28); var hh = 0; - var color_selecting = struct_try_get(_colors, "selecting", COLORS.collection_path_current_bg); + var font = struct_try_get(_params, "font", f_p0); if(!ds_list_empty(subDir) && _hover && point_in_rectangle(_m[0], _m[1], _x, _y, ui(32), _y + hg - 1)) { draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, _x, _y, ui(32), hg, CDEF.main_white, 1); @@ -215,8 +215,7 @@ function DirectoryObject(name, path) constructor { #region if(ds_list_empty(subDir)) draw_sprite_ui_uniform(THEME.folder_content, parent.context == self, _x + ui(16), _y + hg / 2 - 1, 1, COLORS.collection_folder_empty); else draw_sprite_ui_uniform(THEME.folder_content, open, _x + ui(16), _y + hg / 2 - 1, 1, COLORS.collection_folder_nonempty); - if(path == parent.context.path) draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_text_accent); - else draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner); + draw_set_text(font, fa_left, fa_center, path == parent.context.path? COLORS._main_text_accent : COLORS._main_text_inner); draw_text_add(_x + ui(32), _y + hg / 2, name); hh += hg; _y += hg; @@ -224,7 +223,7 @@ function DirectoryObject(name, path) constructor { #region if(open && !ds_list_empty(subDir)) { var l_y = _y; for(var i = 0; i < ds_list_size(subDir); i++) { - var _hg = subDir[| i].draw(parent, _x + ui(16), _y, _m, _w - ui(16), _hover, _focus, _homedir, _colors); + var _hg = subDir[| i].draw(parent, _x + ui(16), _y, _m, _w - ui(16), _hover, _focus, _homedir, _params); draw_set_color(COLORS.collection_tree_line); draw_line(_x + ui(12), _y + hg / 2, _x + ui(16), _y + hg / 2); diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index f86b5b142..b7e9e2d52 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -112,7 +112,7 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr var _spw = sprite_get_width(spr); var _sph = sprite_get_height(spr); - var _ss = grid_size / max(_spw, _sph) * 0.75; + var _ss = grid_size / max(_spw, _sph) * 0.6; gpu_set_tex_filter(true); draw_sprite_uniform(spr, 0, spr_x, spr_y, _ss); @@ -130,7 +130,7 @@ function NodeObject(_name, _spr, _node, _create, tooltip = "", tags = []) constr var fav = array_exists(global.FAV_NODES, node); if(fav) draw_sprite_ui_uniform(THEME.star, 0, _x + grid_size - ui(10), _y + grid_size - ui(10), 0.7, COLORS._main_accent, 1.); - + var spr_x = _x + grid_size - 4; var spr_y = _y + 4; diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 2959e6514..154058c0a 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -2346,8 +2346,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru _s /= 2; var hov = PANEL_GRAPH.pHOVER && (PANEL_GRAPH.node_hovering == noone || PANEL_GRAPH.node_hovering == node); - var _d = 16 * _s; - var is_hover = hov && point_in_rectangle(_mx, _my, x - _d, y - _d, x + _d, y + _d); + var _d = 24 * _s; + var is_hover = hov && point_in_rectangle(_mx, _my, x - _d, y - _d, x + _d - 1, y + _d - 1); hover_in_graph = is_hover; var _bgS = THEME.node_junctions_bg; diff --git a/scripts/panel_collection/panel_collection.gml b/scripts/panel_collection/panel_collection.gml index e1c0675cb..5fe7821f1 100644 --- a/scripts/panel_collection/panel_collection.gml +++ b/scripts/panel_collection/panel_collection.gml @@ -362,8 +362,11 @@ function Panel_Collection() : PanelContent() constructor { draw_set_alpha(1); _y += ui(24); + var _font = f_p0; + var _param = { font : _font }; + for(var i = 0; i < ds_list_size(root.subDir); i++) { - var hg = root.subDir[| i].draw(self, ui(8 + in_dialog * 8), _y, _m, folderPane.w - ui(20), pHOVER && folderPane.hover, pFOCUS, root); + var hg = root.subDir[| i].draw(self, ui(8 + in_dialog * 8), _y, _m, folderPane.w - ui(20), pHOVER && folderPane.hover, pFOCUS, root, _param); hh += hg; _y += hg; } @@ -418,17 +421,13 @@ function Panel_Collection() : PanelContent() constructor { #region resize width if(group_w_dragging) { - CURSOR = cr_size_we; - - var _gw = group_w_sx + (mx - group_w_mx); - _gw = max(ui(180), _gw); - group_w = _gw; + CURSOR = cr_size_we; + group_w = max(ui(128), group_w_sx + (mx - group_w_mx)); onResize(); - if(mouse_release(mb_left)) { + if(mouse_release(mb_left)) group_w_dragging = false; - } } if(pHOVER && point_in_rectangle(mx, my, group_w - ui(2), content_y, group_w + ui(2), content_y + content_h)) { @@ -500,12 +499,10 @@ function Panel_Collection() : PanelContent() constructor { if(bx > rootx) { var txt = __txtx("panel_collection_add_folder", "Add folder"); if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, txt) == 2) { - var dia = dialogCall(o_dialog_file_name, mouse_mx + 8, mouse_my + 8); - dia.onModify = function (txt) { + fileNameCall(context.path, function (txt) { directory_create(txt); refreshContext(); - }; - dia.path = context.path + "/"; + }); } draw_sprite_ui_uniform(THEME.folder_add, 0, bx + bs / 2, by + bs / 2, 1, COLORS._main_icon); draw_sprite_ui_uniform(THEME.folder_add, 1, bx + bs / 2, by + bs / 2, 1, COLORS._main_value_positive); diff --git a/scripts/panel_color/panel_color.gml b/scripts/panel_color/panel_color.gml index 989eee25a..5c13fac64 100644 --- a/scripts/panel_color/panel_color.gml +++ b/scripts/panel_color/panel_color.gml @@ -22,12 +22,18 @@ function Panel_Color() : PanelContent() constructor { colors = []; - hex_tb = new textBox(TEXTBOX_INPUT.text, function(val) { setColor(colorFromHex(val)); }) - alpha_slider = slider(0, 1, 0.01, function(val) { alp = val; setHSV(); }) + hex_tb = new textBox(TEXTBOX_INPUT.text, function(_hx) { setColor(colorFromHex(_hx)); }) + alpha_slider = slider(0, 1, 0.01, function(_a) { alp = _a; setHSV(); }) show_alpha = true; show_palette = false; show_hex = true; + current_color = c_white; + discretize_pal = false; + + content_surface = surface_create(1, 1); + side_surface = surface_create(1, 1); + static setColor = function(color) { CURRENT_COLOR = color; } @@ -37,6 +43,8 @@ function Panel_Color() : PanelContent() constructor { sat = _color_get_saturation(CURRENT_COLOR); val = _color_get_value(CURRENT_COLOR); alp = _color_get_alpha(CURRENT_COLOR); + + current_color = CURRENT_COLOR; } static setHSV = function(h = hue, s = sat, v = val, a = alp) { @@ -45,7 +53,10 @@ function Panel_Color() : PanelContent() constructor { val = v; alp = a; - CURRENT_COLOR = make_color_hsva(h * 255, s * 255, v * 255, a * 255); + var _c = make_color_hsva(h * 255, s * 255, v * 255, a * 255); + + CURRENT_COLOR = _c; + current_color = CURRENT_COLOR; } setHSV(); @@ -109,7 +120,10 @@ function Panel_Color() : PanelContent() constructor { var alp_x = alp_h + ui(padding * 2); var alp_y = _y1 - alp_h; - draw_sprite_stretched_ext(s_ui_base_white, 0, ui(padding), alp_y, alp_h, alp_h, CURRENT_COLOR, show_alpha); + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, ui(padding), alp_y, alp_h, alp_h, CURRENT_COLOR, alp); + BLEND_ADD + draw_sprite_stretched_ext(THEME.menu_button_mask, 1, ui(padding), alp_y, alp_h, alp_h, c_white, 0.3); + BLEND_NORMAL hex_tb.setFocusHover(pFOCUS, pHOVER); hex_tb.setFont(f_p2); @@ -143,47 +157,93 @@ function Panel_Color() : PanelContent() constructor { var cont_w = w - _selPad * 2 - sel_w - sel_pd; var cont_h = _y1 - ui(4) - cont_y; - shader_set(sh_color_select_content); - shader_set_i("mode", mode); - shader_set_f("hue", hue); - shader_set_f("val", val); - draw_sprite_stretched(s_fx_pixel, 0, cont_x, cont_y, cont_w, cont_h); - var sel_x = cont_x + cont_w + sel_pd; var sel_y = _selPad; var sel_h = cont_h; - shader_set(sh_color_select_side); - shader_set_i("mode", mode); - shader_set_f("hue", hue); - draw_sprite_stretched(s_fx_pixel, 0, sel_x, sel_y, sel_w, sel_h); - shader_reset(); + content_surface = surface_verify(content_surface, cont_w, cont_h); + side_surface = surface_verify(side_surface, sel_w, sel_h); + + surface_set_target(content_surface); + DRAW_CLEAR + + draw_sprite_stretched(THEME.menu_button_mask, 0, 0, 0, cont_w, cont_h); + gpu_set_colorwriteenable(1, 1, 1, 0); + shader_set(sh_color_select_content); + shader_set_i("mode", mode); + shader_set_f("hue", hue); + shader_set_f("sat", sat); + shader_set_f("val", val); + + shader_set_i("discretize", discretize_pal); + shader_set_palette(PROJECT.attributes.palette); + + draw_sprite_stretched(s_fx_pixel, 0, 0, 0, cont_w, cont_h); + shader_reset(); + gpu_set_colorwriteenable(1, 1, 1, 1); + + surface_reset_target(); + + surface_set_target(side_surface); + DRAW_CLEAR + + draw_sprite_stretched(THEME.menu_button_mask, 0, 0, 0, sel_w, sel_h); + gpu_set_colorwriteenable(1, 1, 1, 0); + shader_set(sh_color_select_side); + shader_set_i("mode", mode); + shader_set_f("hue", hue); + shader_set_f("sat", sat); + shader_set_f("val", val); + + shader_set_i("discretize", discretize_pal); + shader_set_palette(PROJECT.attributes.palette); + + draw_sprite_stretched(s_fx_pixel, 0, 0, 0, sel_w, sel_h); + shader_reset(); + gpu_set_colorwriteenable(1, 1, 1, 1); + + surface_reset_target(); + + draw_surface(content_surface, cont_x, cont_y); + draw_surface(side_surface, sel_x, sel_y); + + BLEND_ADD + draw_sprite_stretched_ext(THEME.menu_button_mask, 1, cont_x, cont_y, cont_w, cont_h, c_white, 0.3); + draw_sprite_stretched_ext(THEME.menu_button_mask, 1, sel_x, sel_y, sel_w, sel_h, c_white, 0.3); + BLEND_NORMAL if(drag_con) { + var _mmx = clamp((mx - cont_x) / cont_w, 0, 1); + var _mmy = 1 - clamp((my - cont_y) / cont_h, 0, 1); + if(mode == 0) { - sat = clamp((mx - cont_x) / cont_w, 0, 1); - val = 1 - clamp((my - cont_y) / cont_h, 0, 1); + sat = _mmx; + val = _mmy; + } else if(mode == 1) { - hue = clamp((mx - cont_x) / cont_w, 0, 1); - sat = 1 - clamp((my - cont_y) / cont_h, 0, 1); + hue = _mmx; + sat = _mmy; + + } else if(mode == 2) { + hue = _mmx; + val = _mmy; } setHSV(); - if(mouse_release(mb_left)) - drag_con = false; + if(mouse_release(mb_left)) drag_con = false; } if(drag_sel) { - if(mode == 0) - hue = clamp((my - sel_y) / sel_h, 0, 1); - else if(mode == 1) - val = 1 - clamp((my - sel_y) / sel_h, 0, 1); + var _mmy = clamp((my - sel_y) / sel_h, 0, 1); + + if(mode == 0) hue = _mmy; + else if(mode == 1) val = 1 - _mmy; + else if(mode == 2) sat = 1 - _mmy; setHSV(); - - if(mouse_release(mb_left)) - drag_sel = false; + + if(mouse_release(mb_left)) drag_sel = false; } if(mouse_press(mb_left, pFOCUS)) { @@ -194,48 +254,52 @@ function Panel_Color() : PanelContent() constructor { drag_sel = true; } - var _bar_s = ui(12); - var _sd_w = ui(16 + 6); + var bs = ui(12); + var sw = ui(16 + 6); + + var cx = 0; + var cy = 0; + var sx = sel_x - ui(3); + var sy = 0; + var sc = c_black; + var cc = CURRENT_COLOR; if(mode == 0) { var hy = sel_y + hue * sel_h; - var cx = cont_x + sat * cont_w - _bar_s / 2; - var cy = cont_y + (1 - val) * cont_h - _bar_s / 2; + cx = cont_x + sat * cont_w - bs / 2; + cy = cont_y + (1 - val) * cont_h - bs / 2; - var _sd_x = sel_x - ui(3); - var _sd_y = hy - _bar_s / 2; - - draw_sprite_stretched_ext(THEME.menu_button_mask, 0, cx - 1, cy - 1, _bar_s + 2, _bar_s + 2, c_black, 1); - draw_sprite_stretched_ext(THEME.menu_button_mask, 0, _sd_x - 1, _sd_y - 1, _sd_w + 2, _bar_s + 2, c_black, 1); - - draw_sprite_stretched_ext(THEME.menu_button_mask, 0, _sd_x, _sd_y, _sd_w, _bar_s, make_color_hsv(hue * 255, 255, 255), 1); - draw_sprite_stretched_ext(THEME.menu_button_mask, 0, cx, cy, _bar_s, _bar_s, CURRENT_COLOR, 1); - - BLEND_ADD - draw_sprite_stretched_ext(THEME.menu_button_mask, 1, _sd_x, _sd_y, _sd_w, _bar_s, c_white, 0.75); - draw_sprite_stretched_ext(THEME.menu_button_mask, 1, cx, cy, _bar_s, _bar_s, c_white, 0.75); - BLEND_NORMAL + sy = hy - bs / 2; + sc = make_color_hsv(hue * 255, 255, 255); } else if(mode == 1) { var vy = sel_y + (1 - val) * sel_h; - var cx = cont_x + hue * cont_w - _bar_s / 2; - var cy = cont_y + (1 - sat) * cont_h - _bar_s / 2; + cx = cont_x + hue * cont_w - bs / 2; + cy = cont_y + (1 - sat) * cont_h - bs / 2; - var _sd_x = sel_x - ui(3); - var _sd_y = vy - _bar_s / 2; + sy = vy - bs / 2; + sc = make_color_hsv(hue * 255, 255, val * 255); + + } else if(mode == 2) { + var sy = sel_y + (1 - sat) * sel_h; + cx = cont_x + hue * cont_w - bs / 2; + cy = cont_y + (1 - val) * cont_h - bs / 2; - draw_sprite_stretched_ext(THEME.menu_button_mask, 0, cx - 1, cy - 1, _bar_s + 2, _bar_s + 2, c_black, 1); - draw_sprite_stretched_ext(THEME.menu_button_mask, 0, _sd_x - 1, _sd_y - 1, _sd_w + 2, _bar_s + 2, c_black, 1); - - draw_sprite_stretched_ext(THEME.menu_button_mask, 0, _sd_x, _sd_y, _sd_w, _bar_s, make_color_hsv(hue * 255, 255, val * 255), 1); - draw_sprite_stretched_ext(THEME.menu_button_mask, 0, cx, cy, _bar_s, _bar_s, CURRENT_COLOR, 1); - - BLEND_ADD - draw_sprite_stretched_ext(THEME.menu_button_mask, 1, _sd_x, _sd_y, _sd_w, _bar_s, c_white, 0.75); - draw_sprite_stretched_ext(THEME.menu_button_mask, 1, cx, cy, _bar_s, _bar_s, c_white, 0.75); - BLEND_NORMAL + sy = sy - bs / 2; + sc = make_color_hsv(hue * 255, sat * 255, 255); } + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, cx - 1, cy - 1, bs + 2, bs + 2, c_black, 0.1); + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, sx - 1, sy - 1, sw + 2, bs + 2, c_black, 0.1); + + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, sx, sy, sw, bs, sc, 1); + draw_sprite_stretched_ext(THEME.menu_button_mask, 0, cx, cy, bs, bs, cc, 1); + + BLEND_ADD + draw_sprite_stretched_ext(THEME.menu_button_mask, 1, sx, sy, sw, bs, c_white, 0.75); + draw_sprite_stretched_ext(THEME.menu_button_mask, 1, cx, cy, bs, bs, c_white, 0.75); + BLEND_NORMAL + if(DRAGGING && DRAGGING.type == "Color" && pHOVER) { draw_sprite_stretched_ext(THEME.ui_panel_active, 0, 2, 2, w - 4, h - 4, COLORS._main_value_positive, 1); if(mouse_release(mb_left)) @@ -244,12 +308,19 @@ function Panel_Color() : PanelContent() constructor { if(mouse_press(mb_right, pFOCUS)) { menuCall("color_window_menu",,, [ + menuItem(__txt("Hue"), function() { mode = 0; } ), + menuItem(__txt("Value"), function() { mode = 1; } ), + menuItem(__txt("Saturation"), function() { mode = 2; } ), + -1, menuItem(__txt("Toggle Alpha"), function() { show_alpha = !show_alpha; }, noone, noone, function() /*=>*/ {return show_alpha} ), menuItem(__txt("Toggle Palette"), function() { show_palette = !show_palette; }, noone, noone, function() /*=>*/ {return show_palette} ), menuItem(__txt("Toggle Hex"), function() { show_hex = !show_hex; }, noone, noone, function() /*=>*/ {return show_hex} ), + -1, + menuItem(__txt("Discretize"), function() { discretize_pal = !discretize_pal; }, noone, noone, function() /*=>*/ {return discretize_pal} ), ]); } - refreshHSV(); + if(current_color != CURRENT_COLOR) + refreshHSV(); } } \ No newline at end of file diff --git a/scripts/panel_data/panel_data.gml b/scripts/panel_data/panel_data.gml index 353ed8639..385078630 100644 --- a/scripts/panel_data/panel_data.gml +++ b/scripts/panel_data/panel_data.gml @@ -51,6 +51,8 @@ function Panel(_parent, _x, _y, _w, _h) constructor { #region tab_holding_sy = 0; tab_cover = noone; + draw_droppable = false; + border_rb_close = menuItem(__txt("Close"), function() { #region var con = getContent(); if(con == noone) return; @@ -704,13 +706,18 @@ function Panel(_parent, _x, _y, _w, _h) constructor { #region } else if(mouse_press(mb_right)) { var menu = array_clone(border_rb_menu); if(instanceof(getContent()) == "Panel_Menu") - array_remove(menu, 2, border_rb_close); + array_remove(menu, border_rb_close); menuCall("panel_border_menu",,, menu); } } } + if(draw_droppable) { + draw_sprite_stretched_ext(THEME.ui_panel_active, 0, tx + padding, ty + padding, tw - padding * 2, th - padding * 2, COLORS._main_value_positive, 1); + draw_droppable = false; + } + if(o_main.panel_dragging != noone && m_ot && !key_mod_press(CTRL)) checkHover(); } #endregion diff --git a/scripts/panel_file_explorer/panel_file_explorer.gml b/scripts/panel_file_explorer/panel_file_explorer.gml index 5c507dca7..d0e738296 100644 --- a/scripts/panel_file_explorer/panel_file_explorer.gml +++ b/scripts/panel_file_explorer/panel_file_explorer.gml @@ -207,11 +207,15 @@ function Panel_File_Explorer() : PanelContent() constructor { menu_file_image = [ menuItem("Add as node", function() { - Node_create_Image_path(PANEL_GRAPH.graph_cx, PANEL_GRAPH.graph_cy, __menu_file_selecting.path); + var node = Node_create_Image_path(PANEL_GRAPH.graph_cx, PANEL_GRAPH.graph_cy, __menu_file_selecting.path); + PANEL_PREVIEW.setNodePreview(node); + PANEL_INSPECTOR.inspecting = node; }), menuItem("Add as canvas", function() { - nodeBuild("Node_Canvas", PANEL_GRAPH.graph_cx, PANEL_GRAPH.graph_cy).loadImagePath(__menu_file_selecting.path); + var node = nodeBuild("Node_Canvas", PANEL_GRAPH.graph_cx, PANEL_GRAPH.graph_cy).loadImagePath(__menu_file_selecting.path); + PANEL_PREVIEW.setNodePreview(node); + PANEL_INSPECTOR.inspecting = node; }), menuItem("Copy path", function() { clipboard_set_text(__menu_file_selecting.path); }, THEME.copy), @@ -232,7 +236,10 @@ function Panel_File_Explorer() : PanelContent() constructor { surface_save(_s, txt); surface_free(_s); - nodeBuild("Node_Canvas", PANEL_GRAPH.graph_cx, PANEL_GRAPH.graph_cy).loadImagePath(txt); + var node = nodeBuild("Node_Canvas", PANEL_GRAPH.graph_cx, PANEL_GRAPH.graph_cy).loadImagePath(txt); + PANEL_PREVIEW.setNodePreview(node); + PANEL_INSPECTOR.inspecting = node; + __menu_cnxt_selecting.getContent(); }; dia.path = __menu_cnxt_selecting.path + "/"; @@ -324,6 +331,14 @@ function Panel_File_Explorer() : PanelContent() constructor { path_dragging[i] = file_selectings[i].path; } + if(path_dragging != -1 && !array_empty(path_dragging) && !pHOVER) { + if(HOVER && is_instanceof(HOVER, Panel)) { + var _cont = HOVER.getContent(); + if(is_instanceof(_cont, Panel_Preview) || is_instanceof(_cont, Panel_Graph)) + HOVER.draw_droppable = true; + } + } + if(mouse_release(mb_left)) { var _file_focus = file_focus; file_focus = noone; @@ -497,7 +512,10 @@ function Panel_File_Explorer() : PanelContent() constructor { } _bx += _ph + ui(2); if(buttonInstant(noone, _bx, _py, _ph, _ph, _m, pFOCUS, pHOVER, "", THEME.canvas_20, 0, [ COLORS._main_icon, c_white ]) == 2) { - nodeBuild("Node_Canvas", _graph_x, _graph_y).loadImagePath(_fil.path); + var node = nodeBuild("Node_Canvas", _graph_x, _graph_y).loadImagePath(_fil.path); + PANEL_PREVIEW.setNodePreview(node); + PANEL_INSPECTOR.inspecting = node; + draggable = false; } _bx += _ph + ui(2); diff --git a/scripts/panel_function/panel_function.gml b/scripts/panel_function/panel_function.gml index 02f1b07f4..26f0cd16c 100644 --- a/scripts/panel_function/panel_function.gml +++ b/scripts/panel_function/panel_function.gml @@ -70,6 +70,8 @@ case "Panel_Palette_Mixer" : return new Panel_Palette_Mixer(); case "Panel_Gradient" : return new Panel_Gradient(); case "Panel_Console" : return new Panel_Console(); + + case "Panel_Preview_Histogram" : return new Panel_Preview_Histogram(); } return noone; diff --git a/scripts/panel_graph/panel_graph.gml b/scripts/panel_graph/panel_graph.gml index e15827678..41f486794 100644 --- a/scripts/panel_graph/panel_graph.gml +++ b/scripts/panel_graph/panel_graph.gml @@ -1,4 +1,4 @@ -#region funtion calls +#region function calls function __fnInit_Graph() { __registerFunction("graph_add_node", panel_graph_add_node); __registerFunction("graph_focus_content", panel_graph_focus_content); @@ -1385,7 +1385,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { function drawJunctionConnect() { #region - if(value_dragging) { + if(value_dragging) { if(!value_dragging.node.active) { value_dragging = noone; return; } var xx = value_dragging.x; @@ -1394,7 +1394,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { var _my = my; var target = noone; - if(value_focus && value_focus != value_dragging && value_focus.connect_type != value_dragging.connect_type) + if(value_focus && value_focus != value_dragging) target = value_focus; if(key_mod_press(CTRL) && node_hovering != noone) { @@ -1425,29 +1425,49 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor { _inline_ctx.point_y = mouse_graph_y; } - if(mouse_release(mb_left)) { // CONNECT junction + if(mouse_release(mb_left)) { //// CONNECT junction var _connect = [ 0, noone, noone ]; if(PANEL_INSPECTOR && PANEL_INSPECTOR.attribute_hovering != noone) { PANEL_INSPECTOR.attribute_hovering(value_dragging); - } else if(target != noone) { - var _addInput = false; - if(target.value_from == noone && target.connect_type == JUNCTION_CONNECT.input && target.node.auto_input) - _addInput = true; - if(value_dragging.connect_type == JUNCTION_CONNECT.input) { - if(array_empty(value_draggings)) { - _connect = [ value_dragging.setFrom(target), value_dragging, target ]; - } else { - for( var i = 0, n = array_length(value_draggings); i < n; i++ ) - value_draggings[i].setFrom(target); + } else if(target != noone) { + + if(target.connect_type == value_dragging.connect_type) { + + if(value_dragging.connect_type == JUNCTION_CONNECT.input) { + if(target.value_from) { + value_dragging.setFrom(target.value_from); + target.removeFrom(); + } + + } else if(value_dragging.connect_type == JUNCTION_CONNECT.output) { + var _tos = target.getJunctionTo(); + + for (var i = 0, n = array_length(_tos); i < n; i++) + _tos[i].setFrom(value_dragging); } - } else if(_addInput && !array_empty(value_draggings)) { - for( var i = 0, n = array_length(value_draggings); i < n; i++ ) - target.node.addInput(value_draggings[i]); + } else { - _connect = [ target.setFrom(value_dragging), target, value_dragging ]; + var _addInput = target.value_from == noone && target.connect_type == JUNCTION_CONNECT.input && target.node.auto_input; + + if(value_dragging.connect_type == JUNCTION_CONNECT.input) { + if(array_empty(value_draggings)) { + _connect = [ value_dragging.setFrom(target), value_dragging, target ]; + } else { + for( var i = 0, n = array_length(value_draggings); i < n; i++ ) + value_draggings[i].setFrom(target); + } + + } else if(_addInput && !array_empty(value_draggings)) { + for( var i = 0, n = array_length(value_draggings); i < n; i++ ) + target.node.addInput(value_draggings[i]); + + } else { + _connect = [ target.setFrom(value_dragging), target, value_dragging ]; + } } + } else { if(value_dragging.connect_type == JUNCTION_CONNECT.input) value_dragging.removeFrom(); diff --git a/scripts/panel_menu/panel_menu.gml b/scripts/panel_menu/panel_menu.gml index 9504017b7..173d240e0 100644 --- a/scripts/panel_menu/panel_menu.gml +++ b/scripts/panel_menu/panel_menu.gml @@ -228,6 +228,8 @@ function Panel_Menu() : PanelContent() constructor { menuItem(__txt("Palette Mixer"), function() { panelAdd("Panel_Palette_Mixer", true) }, noone, ["", "Palette Mixer Panel"], function() { return findPanel("Panel_Palette_Mixer") != noone; } ), ]); } ).setIsShelf(), + + menuItem(__txt("Histogram"), function() { panelAdd("Panel_Preview_Histogram", true) }, noone, noone, function() { return findPanel("Panel_Preview_Histogram") != noone; } ), ]], [ __txt("Help"), menu_help ], diff --git a/scripts/panel_palette/panel_palette.gml b/scripts/panel_palette/panel_palette.gml index 5e558219d..d9b973fdd 100644 --- a/scripts/panel_palette/panel_palette.gml +++ b/scripts/panel_palette/panel_palette.gml @@ -9,6 +9,9 @@ function Panel_Palette() : PanelContent() constructor { grid_size_to = ui(16); color_dragging = noone; + drag_from_self = false; + + __save_palette_data = []; function onResize() { sp_palettes.resize(w - ui(padding + padding), h - ui(padding + padding)); @@ -29,6 +32,33 @@ function Panel_Palette() : PanelContent() constructor { } grid_size = lerp_float(grid_size, grid_size_to, 3); + if(DRAGGING && DRAGGING.type == "Palette" && !drag_from_self) { + var _add_h = ui(28); + var _hov = pHOVER && point_in_rectangle(_m[0], _m[1], 0, yy, ww, yy + _add_h); + + draw_sprite_stretched_ext(THEME.timeline_node, 0, 0, yy, ww, _add_h, COLORS._main_value_positive, .4); + draw_sprite_stretched_ext(THEME.timeline_node, 1, 0, yy, ww, _add_h, COLORS._main_value_positive, .7 + _hov * .25); + draw_set_text(f_p2, fa_center, fa_center, COLORS._main_value_positive); + draw_text_add(ww / 2, yy + _add_h / 2, __txt("New palette")); + + if(_hov && mouse_release(mb_left)) { + __save_palette_data = DRAGGING.data; + + fileNameCall($"{DIRECTORY}Palettes", function (_path) { + if(filename_ext(_path) != ".hex") _path += ".hex"; + + var _str = palette_string_hex(__save_palette_data, false); + file_text_write_all(_path, _str); + __initPalette(); + }); + } + + yy += _add_h + ui(8); + hh += _add_h + ui(8); + } + + if(mouse_release(mb_left)) drag_from_self = false; + for(var i = 0; i < array_length(PALETTES); i++) { var preset = PALETTES[i]; var pre_amo = array_length(preset.palette); @@ -52,7 +82,7 @@ function Panel_Palette() : PanelContent() constructor { if(point_in_rectangle(_m[0], _m[1], ui(10), yy + ui(24), ww - ui(10), yy + ui(24) + _height)) { var m_ax = _m[0] - ui(10); var m_ay = _m[1] - (yy + ui(24)); - + var m_gx = floor(m_ax / _gs); var m_gy = floor(m_ay / _gs); @@ -72,6 +102,7 @@ function Panel_Palette() : PanelContent() constructor { data: preset.palette } MESSAGE = DRAGGING; + drag_from_self = true; } } diff --git a/scripts/panel_palette_mixer/panel_palette_mixer.gml b/scripts/panel_palette_mixer/panel_palette_mixer.gml index 52e157d50..8c16b7089 100644 --- a/scripts/panel_palette_mixer/panel_palette_mixer.gml +++ b/scripts/panel_palette_mixer/panel_palette_mixer.gml @@ -61,6 +61,10 @@ function Panel_Palette_Mixer() : PanelContent() constructor { connection_drag = noone; conn_menu_ctx = noone; + pal_draging = false; + pal_drag_mx = 0; + pal_drag_my = 0; + shade_mode = 0; pr_palette = ds_priority_create(); @@ -78,7 +82,7 @@ function Panel_Palette_Mixer() : PanelContent() constructor { var _connections = palette_data.connections; var _blends = palette_data.blends; - if(key_mod_press(SHIFT)) shade_mode = lerp_float(shade_mode, 1, 10); + if(key_mod_press(SHIFT)) shade_mode = lerp_float(shade_mode, 1, 20); else shade_mode = lerp_float(shade_mode, 0, 10); if(!in_dialog) draw_sprite_stretched(THEME.ui_panel_bg, 1, 0, 0, w, h); @@ -118,9 +122,6 @@ function Panel_Palette_Mixer() : PanelContent() constructor { if(pHOVER && point_in_rectangle(mx, my, pbg_x, pbg_y, pbg_x + pbg_w, pbg_y + pbg_h)) { draw_sprite_stretched_ext(THEME.button_def, 3, pbg_x, pbg_y, pbg_w, pbg_h, c_white, 0.5); - if(mouse_press(mb_right)) { - //////////////////////////////////////////// - } } ds_priority_clear(pr_palette); @@ -184,10 +185,8 @@ function Panel_Palette_Mixer() : PanelContent() constructor { var _by = pal_y; var _bs = ui(24); - if(buttonInstant(THEME.button_hide, _bx, _by, _bs, pal_h, [ mx, my ], pFOCUS, pHOVER, "", THEME.hamburger_s) == 2) { - // DRAGGING = { type: "Palette", data: palette } - // MESSAGE = DRAGGING; - + var _b = buttonInstant(THEME.button_hide, _bx, _by, _bs, pal_h, [ mx, my ], pFOCUS, pHOVER, "", THEME.hamburger_s); + if(_b == 2) { menuCall("",,, [ menuItem("Save palette as...", function() { var _path = get_save_filename_pxc("Hex paleete|*.hex", "Palette"); @@ -201,6 +200,23 @@ function Panel_Palette_Mixer() : PanelContent() constructor { } }), ]); + + pal_draging = true; + pal_drag_mx = mx; + pal_drag_my = my; + } + + if(pal_draging) { + if(point_distance(pal_drag_mx, pal_drag_my, mx, my) > 8) { + DRAGGING = { type: "Palette", data: palette }; + MESSAGE = DRAGGING; + pal_draging = false; + + instance_destroy(o_dialog_menubox); + } + + if(mouse_release(mb_left)) + pal_draging = false; } #endregion @@ -459,11 +475,11 @@ function Panel_Palette_Mixer() : PanelContent() constructor { menuItem("Save mixed...", function() { var _path = get_save_filename_pxc("JSON|*.json", "New mixed"); if(_path != "") save_palette_mixer(palette_data, _path); - }), + }, THEME.save), menuItem("Load mixed...", function() { var _path = get_open_filename_pxc("JSON|*.json", ""); if(_path != "") palette_data = load_palette_mixer(_path); - }), + }, THEME.noti_icon_file_load), -1, menuItem("Clear palette", function() { palette_data = { nodes: [], connections: [], blends: [], } }, THEME.cross), ]); diff --git a/scripts/panel_preview_histogram/panel_preview_histogram.gml b/scripts/panel_preview_histogram/panel_preview_histogram.gml new file mode 100644 index 000000000..63754d88d --- /dev/null +++ b/scripts/panel_preview_histogram/panel_preview_histogram.gml @@ -0,0 +1,52 @@ +function Panel_Preview_Histogram() : PanelContent() constructor { + title = __txt("Histogram"); + padding = 8; + + w = ui(320); + h = ui(240); + + bg_surf = surface_create(32, 32); + ch_surf = [ noone, noone, noone, noone, ]; + + function drawContent(panel) { + draw_clear_alpha(COLORS.panel_bg_clear, 0); + draw_sprite_stretched(THEME.ui_panel_bg, 1, 0, 0, w, h); + + var _s = PANEL_PREVIEW.getNodePreviewSurface(); + if(!surface_exists(_s)) return; + + bg_surf = surface_verify(bg_surf, 32, 32); + for (var i = 0, n = array_length(ch_surf); i < n; i++) + ch_surf[i] = surface_verify(ch_surf[i], w, h); + + gpu_set_texfilter(true); + surface_set_target(bg_surf); + DRAW_CLEAR + draw_surface_stretched(_s, 0, 0, 32, 32); + surface_reset_target(); + gpu_set_texfilter(false); + + for(var i = 0; i < 4; i++) + surface_set_target_ext(i, ch_surf[i]); + + shader_set(sh_preview_histogram); + DRAW_CLEAR + + shader_set_surface("surface", bg_surf); + shader_set_color("color", CDEF.main_grey); + + draw_sprite_stretched(s_fx_pixel, 0, 0, 0, w, h); + shader_reset(); + surface_reset_target(); + + draw_surface_ext(ch_surf[0], 0, 0, 1, 1, 0, CDEF.main_grey, 1); + + shader_set(sh_preview_histogram_outline); + shader_set_f("dimension", w, h); + + draw_surface_ext(ch_surf[1], 0, 0, 1, 1, 0, c_red, 1); + draw_surface_ext(ch_surf[2], 0, 0, 1, 1, 0, c_lime, 1); + draw_surface_ext(ch_surf[3], 0, 0, 1, 1, 0, c_blue, 1); + shader_reset(); + } +} \ No newline at end of file diff --git a/scripts/panel_preview_histogram/panel_preview_histogram.yy b/scripts/panel_preview_histogram/panel_preview_histogram.yy new file mode 100644 index 000000000..1873069b0 --- /dev/null +++ b/scripts/panel_preview_histogram/panel_preview_histogram.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"", + "%Name":"panel_preview_histogram", + "isCompatibility":false, + "isDnD":false, + "name":"panel_preview_histogram", + "parent":{ + "name":"preview", + "path":"folders/panels/preview.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/shaders/sh_color_picker_side_hue/sh_color_picker_side_hue.fsh b/shaders/sh_color_picker_side_hue/sh_color_picker_side_hue.fsh index bd6a7b562..43e9efd35 100644 --- a/shaders/sh_color_picker_side_hue/sh_color_picker_side_hue.fsh +++ b/shaders/sh_color_picker_side_hue/sh_color_picker_side_hue.fsh @@ -22,10 +22,8 @@ vec3 hsv2rgb(vec3 c) { void main() { vec3 _rgb; - if(usePalette == 0) - _rgb = hsv2rgb(vec3(v_vTexcoord.y, 1., 1.)); - else if(usePalette == 1) - _rgb = hsv2rgb(vec3(v_vTexcoord.y, sat, value)); + if(usePalette == 0) _rgb = hsv2rgb(vec3(v_vTexcoord.y, 1., 1.)); + else if(usePalette == 1) _rgb = hsv2rgb(vec3(v_vTexcoord.y, sat, value)); vec4 color = vec4(_rgb.r, _rgb.g, _rgb.b, v_vColour.a); diff --git a/shaders/sh_color_select_content/sh_color_select_content.fsh b/shaders/sh_color_select_content/sh_color_select_content.fsh index 6746879ba..3aa8e8c7f 100644 --- a/shaders/sh_color_select_content/sh_color_select_content.fsh +++ b/shaders/sh_color_select_content/sh_color_select_content.fsh @@ -1,12 +1,16 @@ -// -// Simple passthrough fragment shader -// +#define PALETTE_LIMIT 128 + varying vec2 v_vTexcoord; varying vec4 v_vColour; uniform int mode; uniform float hue; uniform float val; +uniform float sat; + +uniform int discretize; +uniform vec4 palette[PALETTE_LIMIT]; +uniform int paletteAmount; vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); @@ -16,9 +20,26 @@ vec3 hsv2rgb(vec3 c) { void main() { vec4 col = texture2D( gm_BaseTexture, v_vTexcoord ); + vec4 c; - if(mode == 0) - gl_FragColor = vec4(hsv2rgb(vec3(hue, v_vTexcoord.x, 1. - v_vTexcoord.y)), col.a); - else if(mode == 1) - gl_FragColor = vec4(hsv2rgb(vec3(v_vTexcoord.x, 1. - v_vTexcoord.y, val)), col.a); + if(mode == 0) c = vec4(hsv2rgb(vec3(hue, v_vTexcoord.x, 1. - v_vTexcoord.y)), col.a); + else if(mode == 1) c = vec4(hsv2rgb(vec3(v_vTexcoord.x, 1. - v_vTexcoord.y, val)), col.a); + else if(mode == 2) c = vec4(hsv2rgb(vec3(v_vTexcoord.x, sat, 1. - v_vTexcoord.y)), col.a); + + if(discretize == 1) { + int index = 0; + float minDist = 999.; + for(int i = 0; i < paletteAmount; i++) { + float dist = distance(c.rgb, palette[i].rgb); + + if(dist < minDist) { + minDist = dist; + index = i; + } + } + + c = palette[index]; + } + + gl_FragColor = c; } diff --git a/shaders/sh_color_select_side/sh_color_select_side.fsh b/shaders/sh_color_select_side/sh_color_select_side.fsh index 17612d177..dd3c89b5d 100644 --- a/shaders/sh_color_select_side/sh_color_select_side.fsh +++ b/shaders/sh_color_select_side/sh_color_select_side.fsh @@ -1,11 +1,16 @@ -// -// Simple passthrough fragment shader -// +#define PALETTE_LIMIT 128 + varying vec2 v_vTexcoord; varying vec4 v_vColour; uniform int mode; uniform float hue; +uniform float val; +uniform float sat; + +uniform int discretize; +uniform vec4 palette[PALETTE_LIMIT]; +uniform int paletteAmount; vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); @@ -14,8 +19,26 @@ vec3 hsv2rgb(vec3 c) { } void main() { - if(mode == 0) - gl_FragColor = vec4(hsv2rgb(vec3(v_vTexcoord.y, 1., 1.)), 1.); - else if(mode == 1) - gl_FragColor = vec4(hsv2rgb(vec3(hue, 1., 1. - v_vTexcoord.y)), 1.); + vec4 c; + + if(mode == 0) c = vec4(hsv2rgb(vec3(v_vTexcoord.y, 1., 1.)), 1.); + else if(mode == 1) c = vec4(hsv2rgb(vec3(hue, 1., 1. - v_vTexcoord.y)), 1.); + else if(mode == 2) c = vec4(hsv2rgb(vec3(hue, 1. - v_vTexcoord.y, 1.)), 1.); + + if(discretize == 1) { + int index = 0; + float minDist = 999.; + for(int i = 0; i < paletteAmount; i++) { + float dist = distance(c.rgb, palette[i].rgb); + + if(dist < minDist) { + minDist = dist; + index = i; + } + } + + c = palette[index]; + } + + gl_FragColor = c; } diff --git a/shaders/sh_preview_histogram/sh_preview_histogram.fsh b/shaders/sh_preview_histogram/sh_preview_histogram.fsh new file mode 100644 index 000000000..5daed1a12 --- /dev/null +++ b/shaders/sh_preview_histogram/sh_preview_histogram.fsh @@ -0,0 +1,42 @@ +#define DIM 32. + +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec4 color; +uniform sampler2D surface; + +void main() { + vec3 brv = vec3(0.2126, 0.7152, 0.0722); + + float tx = 1. / DIM; + float rng = 0.1; + float brF = v_vTexcoord.x - rng; + float brT = v_vTexcoord.x + rng; + + float w = 0.; + float r = 0.; + float g = 0.; + float b = 0.; + + for(float x = 0.; x < DIM; x++) + for(float y = 0.; y < DIM; y++) { + vec4 c = texture2D( surface, vec2(x + 0.5, y + 0.5) * tx ); + float br = dot(c.rgb, brv); + + if(br > brF && br <= brT) w++; + if(c.r > brF && c.r <= brT) r++; + if(c.g > brF && c.g <= brT) g++; + if(c.b > brF && c.b <= brT) b++; + } + + float ws = 1. - w / (DIM * DIM); + float rs = 1. - r / (DIM * DIM); + float gs = 1. - g / (DIM * DIM); + float bs = 1. - b / (DIM * DIM); + + gl_FragData[0] = vec4(step(ws, v_vTexcoord.y)); + gl_FragData[1] = vec4(step(rs, v_vTexcoord.y)); + gl_FragData[2] = vec4(step(gs, v_vTexcoord.y)); + gl_FragData[3] = vec4(step(bs, v_vTexcoord.y)); +} diff --git a/shaders/sh_preview_histogram/sh_preview_histogram.vsh b/shaders/sh_preview_histogram/sh_preview_histogram.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_preview_histogram/sh_preview_histogram.vsh @@ -0,0 +1,19 @@ +// +// Simple passthrough vertex shader +// +attribute vec3 in_Position; // (x,y,z) +//attribute vec3 in_Normal; // (x,y,z) unused in this shader. +attribute vec4 in_Colour; // (r,g,b,a) +attribute vec2 in_TextureCoord; // (u,v) + +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +void main() +{ + vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); + gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; + + v_vColour = in_Colour; + v_vTexcoord = in_TextureCoord; +} diff --git a/shaders/sh_preview_histogram/sh_preview_histogram.yy b/shaders/sh_preview_histogram/sh_preview_histogram.yy new file mode 100644 index 000000000..6d5a17cee --- /dev/null +++ b/shaders/sh_preview_histogram/sh_preview_histogram.yy @@ -0,0 +1,12 @@ +{ + "$GMShader":"", + "%Name":"sh_preview_histogram", + "name":"sh_preview_histogram", + "parent":{ + "name":"histogram", + "path":"folders/shader/UI/histogram.yy", + }, + "resourceType":"GMShader", + "resourceVersion":"2.0", + "type":1, +} \ No newline at end of file diff --git a/shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.fsh b/shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.fsh new file mode 100644 index 000000000..62c90938c --- /dev/null +++ b/shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.fsh @@ -0,0 +1,18 @@ +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +uniform vec2 dimension; + +void main() { + vec2 tx = 1. / dimension; + + gl_FragColor = vec4(0.); + + float a = texture2D( gm_BaseTexture, v_vTexcoord ).a; + if(a > 0.) return; + + a = texture2D( gm_BaseTexture, v_vTexcoord + vec2( tx.x, 0.) ).a; if(a > 0.) gl_FragColor = v_vColour; + a = texture2D( gm_BaseTexture, v_vTexcoord + vec2(-tx.x, 0.) ).a; if(a > 0.) gl_FragColor = v_vColour; + a = texture2D( gm_BaseTexture, v_vTexcoord + vec2(0., tx.y) ).a; if(a > 0.) gl_FragColor = v_vColour; + a = texture2D( gm_BaseTexture, v_vTexcoord + vec2(0., -tx.y) ).a; if(a > 0.) gl_FragColor = v_vColour; +} diff --git a/shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.vsh b/shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.vsh @@ -0,0 +1,19 @@ +// +// Simple passthrough vertex shader +// +attribute vec3 in_Position; // (x,y,z) +//attribute vec3 in_Normal; // (x,y,z) unused in this shader. +attribute vec4 in_Colour; // (r,g,b,a) +attribute vec2 in_TextureCoord; // (u,v) + +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +void main() +{ + vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); + gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; + + v_vColour = in_Colour; + v_vTexcoord = in_TextureCoord; +} diff --git a/shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.yy b/shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.yy new file mode 100644 index 000000000..0bb166064 --- /dev/null +++ b/shaders/sh_preview_histogram_outline/sh_preview_histogram_outline.yy @@ -0,0 +1,12 @@ +{ + "$GMShader":"", + "%Name":"sh_preview_histogram_outline", + "name":"sh_preview_histogram_outline", + "parent":{ + "name":"histogram", + "path":"folders/shader/UI/histogram.yy", + }, + "resourceType":"GMShader", + "resourceVersion":"2.0", + "type":1, +} \ No newline at end of file