1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Fixed layer opacity not working when merging layers

This commit is contained in:
OverloadedOrama 2020-01-03 02:44:37 +02:00
parent cf8229a4ae
commit bd9c2c6dd0
5 changed files with 7 additions and 68 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B

View file

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Canvas_split.png-5508e200bf1cdd5667f0f6bb5fb97913.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Graphics/Canvas_split.png"
dest_files=[ "res://.import/Canvas_split.png-5508e200bf1cdd5667f0f6bb5fb97913.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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B

View file

@ -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

View file

@ -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