From 9c0f7bf2986e53a581e48829b4d483100d6fb6fd Mon Sep 17 00:00:00 2001 From: Tanasart Date: Fri, 5 Jul 2024 09:06:33 +0700 Subject: [PATCH] - [Export Graph] Fix "solid background" not completely opaque. --- scripts/panel_animation/panel_animation.gml | 6 +- .../panel_graph_export_image.gml | 70 ++++++++++++------- 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/scripts/panel_animation/panel_animation.gml b/scripts/panel_animation/panel_animation.gml index 35ad24cb6..00d6fb52f 100644 --- a/scripts/panel_animation/panel_animation.gml +++ b/scripts/panel_animation/panel_animation.gml @@ -1953,6 +1953,9 @@ function Panel_Animation() : PanelContent() constructor { if(_hov) keyframe_boxable = false; } + draw_set_color(COLORS.panel_animation_timeline_top); + draw_rectangle(0, 0, bar_w, hh, false); + var _fr = ceil((bar_w / timeline_scale - timeline_shift) / timeline_separate) * timeline_separate; for(var i = timeline_separate; i <= _fr; i += timeline_separate) { @@ -2031,9 +2034,6 @@ function Panel_Animation() : PanelContent() constructor { } } - draw_set_color(COLORS.panel_animation_timeline_top); - draw_rectangle(0, 0, bar_w, hh, false); - draw_set_font(f_p2); var cf = string(CURRENT_FRAME + 1); var tx = string_width(cf) + ui(4); diff --git a/scripts/panel_graph_export_image/panel_graph_export_image.gml b/scripts/panel_graph_export_image/panel_graph_export_image.gml index fce51e138..80bc5836a 100644 --- a/scripts/panel_graph_export_image/panel_graph_export_image.gml +++ b/scripts/panel_graph_export_image/panel_graph_export_image.gml @@ -43,14 +43,14 @@ function graph_export_image(allList, nodeList, settings = {}) { var s = surface_create(bbox_w, bbox_h); var cs = surface_create(bbox_w * aa, bbox_h * aa); + var gr_x = -bbox_x0; + var gr_y = -bbox_y0; + var mx = gr_x, my = gr_y; + surface_set_target(s); //draw nodes if(bgEnable) draw_clear(bgColor); else draw_clear_alpha(0, 0); - - var gr_x = -bbox_x0; - var gr_y = -bbox_y0; - var mx = gr_x, my = gr_y; - + if(gridEnable) { var gls = 32; var gr_ls = gls * scale; @@ -105,13 +105,12 @@ function graph_export_image(allList, nodeList, settings = {}) { surface_reset_target(); shader_set(sh_downsample); - shader_set_f("down", aa); - shader_set_f("dimension", surface_get_width_safe(cs), surface_get_height_safe(cs)); - draw_surface(cs, 0, 0); + shader_set_f("down", aa); + shader_set_f("dimension", surface_get_width_safe(cs), surface_get_height_safe(cs)); + draw_surface(cs, 0, 0); shader_reset(); - surface_free(cs); #endregion - + #region draw node for(var i = 0; i < array_length(nodeList); i++) nodeList[i].onDrawNodeBehind(gr_x, gr_y, mx, my, scale); @@ -125,25 +124,46 @@ function graph_export_image(allList, nodeList, settings = {}) { surface_reset_target(); - if(borderPad == 0) return s; - var _sg = surface_create(bbox_w + borderPad * 2, bbox_h + borderPad * 2); - surface_set_target(_sg); - if(bgEnable) draw_clear(bgColor); - else draw_clear_alpha(0, 0); + if(borderPad == 0) { + surface_set_target(_sg); + if(bgEnable) { + draw_clear(bgColor); + gpu_set_colorwriteenable(1, 1, 1, 0); + } else + draw_clear_alpha(0, 0); + + BLEND_OVERRIDE + draw_surface(s, borderPad, borderPad); + BLEND_NORMAL + + gpu_set_colorwriteenable(1, 1, 1, 1); + surface_reset_target(); - BLEND_ALPHA_MULP - draw_surface(s, borderPad, borderPad); - - draw_set_color(borderColor); - draw_set_alpha(borderAlpha); - draw_rectangle(borderPad, borderPad, bbox_w + borderPad, bbox_h + borderPad, 1); - draw_set_alpha(1); - BLEND_NORMAL - surface_reset_target(); - + } else { + surface_set_target(_sg); + if(bgEnable) { + draw_clear(bgColor); + gpu_set_colorwriteenable(1, 1, 1, 0); + } else + draw_clear_alpha(0, 0); + + BLEND_ALPHA_MULP + draw_surface(s, borderPad, borderPad); + + draw_set_color(borderColor); + draw_set_alpha(borderAlpha); + draw_rectangle(borderPad, borderPad, bbox_w + borderPad, bbox_h + borderPad, 1); + draw_set_alpha(1); + BLEND_NORMAL + + gpu_set_colorwriteenable(1, 1, 1, 1); + surface_reset_target(); + } + surface_free(cs); surface_free(s); + return _sg; } \ No newline at end of file