Created a new Cel class, to handle cel information

Like the Layer class, it is used in place of Canvas.layers nested array mess. It hasn't been tested thoroughly yet, so there may be crashes.
This commit is contained in:
OverloadedOrama 2020-06-01 18:50:31 +03:00
parent f246ed1a7a
commit df0032c515
15 changed files with 108 additions and 110 deletions

View file

@ -367,13 +367,13 @@ func blend_layers(image: Image, canvas: Canvas, origin: Vector2 = Vector2(0, 0))
for layer in canvas.layers:
if Global.layers[layer_i].visible:
var layer_image := Image.new()
layer_image.copy_from(layer[0])
layer_image.copy_from(layer.image)
layer_image.lock()
if layer[2] < 1: # If we have layer transparency
if layer.opacity < 1: # If we have layer transparency
for xx in layer_image.get_size().x:
for yy in layer_image.get_size().y:
var pixel_color := layer_image.get_pixel(xx, yy)
var alpha : float = pixel_color.a * layer[2]
var alpha : float = pixel_color.a * layer.opacity
layer_image.set_pixel(xx, yy, Color(pixel_color.r, pixel_color.g, pixel_color.b, alpha))
DrawingAlgos.blend_rect(image, layer_image, Rect2(canvas.position, canvas.size), origin)
layer_i += 1