mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +00:00
Add a blend_layers_headless
method to DrawingAlgos
This commit is contained in:
parent
19e4c94fe3
commit
bdc1b5af11
|
@ -51,18 +51,7 @@ func blend_layers(
|
|||
include = false
|
||||
var cel := frame.cels[ordered_index]
|
||||
if DisplayServer.get_name() == "headless":
|
||||
var opacity := cel.get_final_opacity(layer)
|
||||
var cel_image := Image.new()
|
||||
cel_image.copy_from(cel.get_image())
|
||||
if opacity < 1.0: # If we have cel or layer transparency
|
||||
for xx in cel_image.get_size().x:
|
||||
for yy in cel_image.get_size().y:
|
||||
var pixel_color := cel_image.get_pixel(xx, yy)
|
||||
var alpha := pixel_color.a * opacity
|
||||
cel_image.set_pixel(
|
||||
xx, yy, Color(pixel_color.r, pixel_color.g, pixel_color.b, alpha)
|
||||
)
|
||||
image.blend_rect(cel_image, Rect2i(Vector2i.ZERO, project.size), origin)
|
||||
blend_layers_headless(image, project, layer, cel, origin)
|
||||
else:
|
||||
var cel_image := layer.display_effects(cel)
|
||||
textures.append(cel_image)
|
||||
|
@ -100,6 +89,21 @@ func set_layer_metadata_image(
|
|||
image.set_pixel(index, 3, Color.BLACK)
|
||||
|
||||
|
||||
func blend_layers_headless(
|
||||
image: Image, project: Project, layer: BaseLayer, cel: BaseCel, origin: Vector2i
|
||||
) -> void:
|
||||
var opacity := cel.get_final_opacity(layer)
|
||||
var cel_image := Image.new()
|
||||
cel_image.copy_from(cel.get_image())
|
||||
if opacity < 1.0: # If we have cel or layer transparency
|
||||
for xx in cel_image.get_size().x:
|
||||
for yy in cel_image.get_size().y:
|
||||
var pixel_color := cel_image.get_pixel(xx, yy)
|
||||
pixel_color.a *= opacity
|
||||
cel_image.set_pixel(xx, yy, pixel_color)
|
||||
image.blend_rect(cel_image, Rect2i(Vector2i.ZERO, project.size), origin)
|
||||
|
||||
|
||||
## Algorithm based on http://members.chello.at/easyfilter/bresenham.html
|
||||
func get_ellipse_points(pos: Vector2i, size: Vector2i) -> Array[Vector2i]:
|
||||
var array: Array[Vector2i] = []
|
||||
|
|
|
@ -22,15 +22,7 @@ func blend_children(frame: Frame, origin := Vector2i.ZERO) -> Image:
|
|||
image.blend_rect(layer.blend_children(frame, origin), blend_rect, origin)
|
||||
else:
|
||||
var cel := frame.cels[layer.index]
|
||||
var cel_image := Image.new()
|
||||
cel_image.copy_from(cel.get_image())
|
||||
if cel.get_final_opacity(layer) < 1.0: # If we have cel transparency
|
||||
for xx in cel_image.get_size().x:
|
||||
for yy in cel_image.get_size().y:
|
||||
var pixel_color := cel_image.get_pixel(xx, yy)
|
||||
pixel_color.a *= cel.opacity
|
||||
cel_image.set_pixel(xx, yy, pixel_color)
|
||||
image.blend_rect(cel_image, blend_rect, origin)
|
||||
DrawingAlgos.blend_layers_headless(image, project, layer, cel, origin)
|
||||
return image
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue