Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Lisandro Lorea | |
Old Version | Published before Godot 3 was released. |
I’m using Godot 2.1.4 and blend_rect_mask seems to be doing the same as blit_rect_mask. That is, it’s not blending, just blitting every pixel where the mask’s alpha is !=0. Is this a bug or am I doing something wrong?
I tried both png and webp formats and checked that both the src image and the mask have an alpha channel.
extends Node2D
onready var canvas = get_node("canvas")
var brush = Image()
var color = Image()
var image = Image()
var tex
func _ready():
print("Initialized")
image.load("res://images/canvas.png")
brush.load("res://images/star2.webp")
color.load("res://images/red.png")
tex = ImageTexture.new()
tex.create_from_image(image)
canvas.set_texture(tex)
set_process(true)
set_process_unhandled_input(true)
func _unhandled_input(event):
if event.is_action_pressed("click"):
var mouse_pos = get_global_mouse_pos()
image.blend_rect_mask(color, brush, brush.get_used_rect(), mouse_pos - 0.5 * brush.get_used_rect().size )
#image.blend_rect(brush, brush.get_used_rect(), mouse_pos - 0.5 * brush.get_used_rect().size )
#image.brush_transfer(color, color, mouse_pos)
tex.create_from_image(image)
canvas.set_texture(tex)