From bd9c2c6dd0636cd6cabf6a83ac3e58ddb3c27957 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Fri, 3 Jan 2020 02:44:37 +0200 Subject: [PATCH] Fixed layer opacity not working when merging layers --- Assets/Graphics/Canvas_split.png | Bin 546 -> 0 bytes Assets/Graphics/Canvas_split.png.import | 34 ---------------------- Assets/Graphics/Canvas_unsplit.png | Bin 546 -> 0 bytes Assets/Graphics/Canvas_unsplit.png.import | 34 ---------------------- Scripts/Main.gd | 7 +++++ 5 files changed, 7 insertions(+), 68 deletions(-) delete mode 100644 Assets/Graphics/Canvas_split.png delete mode 100644 Assets/Graphics/Canvas_split.png.import delete mode 100644 Assets/Graphics/Canvas_unsplit.png delete mode 100644 Assets/Graphics/Canvas_unsplit.png.import diff --git a/Assets/Graphics/Canvas_split.png b/Assets/Graphics/Canvas_split.png deleted file mode 100644 index b6e0c987e7498050dbf05a6c80f38fa8b36d8518..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 546 zcmV+-0^R+IP)EX>4Tx04R}tkv&MmKpe$iQ>CI6hju8UkfFM0K~%(1s#pXIrLEAagUO{|(4-+r zad8w}3l4rPRvlcNb#-tR1i=pw7gr}m7b)?7X`w}o2gm(*ckglc4iM^PrkY(7fT~$W zG8Ppx*;Uc^iarb@fDpzcX6o_OVj8aF>mDAy-bHwp`?)_yzmhW<;1P-Em~L3a8^kl4 zmd<&fILL~ULVQjUyKw?|pMfi_?XT2<*-z4I zZ7qBR3~U1z*KJMS11@)f(3371k|TL(3i&+nen#Jv1p>D~?^?6B);>-jfHZZrd;=UD z0;2`WUUzwSPiJrco@w>>1H!R##~@DgSpWb432;bRa{vGi!vFvd!vV){sAK>D00Lr5 zM??UGKv-l80000rNklEX>4Tx04R}tkv&MmKpe$iQ>CI6hju8UkfFM0K~%(1s#pXIrLEAagUO{|(4-+r zad8w}3l4rPRvlcNb#-tR1i=pw7gr}m7b)?7X`w}o2gm(*ckglc4iM^PrkY(7fT~$W zG8Ppx*;Uc^iarb@fDpzcX6o_OVj8aF>mDAy-bHwp`?)_yzmhW<;1P-Em~L3a8^kl4 zmd<&fILL~ULVQjUyKw?|pMfi_?XT2<*-z4I zZ7qBR3~U1z*KJMS11@)f(3371k|TL(3i&+nen#Jv1p>D~?^?6B);>-jfHZZrd;=UD z0;2`WUUzwSPiJrco@w>>1H!R##~@DgSpWb432;bRa{vGi!vFvd!vV){sAK>D00Lr5 zM??UGKv-l80000rNklrB?;>y kY!^a;u)pwy2A(hk0Em*=(y?=yS^xk507*qoM6N<$f`fP8e*gdg diff --git a/Assets/Graphics/Canvas_unsplit.png.import b/Assets/Graphics/Canvas_unsplit.png.import deleted file mode 100644 index 71668186b..000000000 --- a/Assets/Graphics/Canvas_unsplit.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/Canvas_unsplit.png-26c4de7c36c0d167fcb3541bbe59e403.stex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://Assets/Graphics/Canvas_unsplit.png" -dest_files=[ "res://.import/Canvas_unsplit.png-26c4de7c36c0d167fcb3541bbe59e403.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/bptc_ldr=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=false -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -process/invert_color=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/Scripts/Main.gd b/Scripts/Main.gd index e2ca454ba..aaa95816f 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -689,10 +689,17 @@ func _on_MergeLayer_pressed() -> void: var new_layers: Array = Global.canvas.layers.duplicate() new_layers.remove(Global.canvas.current_layer_index) var selected_layer = Global.canvas.layers[Global.canvas.current_layer_index][0] + if Global.canvas.layers[Global.canvas.current_layer_index][4] < 1: # If we have layer transparency + for xx in selected_layer.get_size().x: + for yy in selected_layer.get_size().y: + var pixel_color : Color = selected_layer.get_pixel(xx, yy) + var alpha : float = pixel_color.a * Global.canvas.layers[Global.canvas.current_layer_index][4] + selected_layer.set_pixel(xx, yy, Color(pixel_color.r, pixel_color.g, pixel_color.b, alpha)) var new_layer := Image.new() new_layer.copy_from(Global.canvas.layers[Global.canvas.current_layer_index - 1][0]) new_layer.lock() + Global.canvas.blend_rect(new_layer, selected_layer, Rect2(Global.canvas.position, Global.canvas.size), Vector2.ZERO) Global.undos += 1