mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +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
|
include = false
|
||||||
var cel := frame.cels[ordered_index]
|
var cel := frame.cels[ordered_index]
|
||||||
if DisplayServer.get_name() == "headless":
|
if DisplayServer.get_name() == "headless":
|
||||||
var opacity := cel.get_final_opacity(layer)
|
blend_layers_headless(image, project, layer, cel, origin)
|
||||||
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)
|
|
||||||
else:
|
else:
|
||||||
var cel_image := layer.display_effects(cel)
|
var cel_image := layer.display_effects(cel)
|
||||||
textures.append(cel_image)
|
textures.append(cel_image)
|
||||||
|
@ -100,6 +89,21 @@ func set_layer_metadata_image(
|
||||||
image.set_pixel(index, 3, Color.BLACK)
|
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
|
## Algorithm based on http://members.chello.at/easyfilter/bresenham.html
|
||||||
func get_ellipse_points(pos: Vector2i, size: Vector2i) -> Array[Vector2i]:
|
func get_ellipse_points(pos: Vector2i, size: Vector2i) -> Array[Vector2i]:
|
||||||
var array: 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)
|
image.blend_rect(layer.blend_children(frame, origin), blend_rect, origin)
|
||||||
else:
|
else:
|
||||||
var cel := frame.cels[layer.index]
|
var cel := frame.cels[layer.index]
|
||||||
var cel_image := Image.new()
|
DrawingAlgos.blend_layers_headless(image, project, layer, cel, origin)
|
||||||
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)
|
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue