1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Use Image class' blend_rect method if Godot's version is 3.2.2

https://github.com/godotengine/godot/issues/31124 has now been fixed in Godot 3.2.2-rc1, so we can use Image.blend_rect() instead of a custom method. This makes exporting large images and drawing with large brush sizes a lot faster.

Once Godot 3.2.2 stable is released, the custom blend_rect method will be completely removed.
This commit is contained in:
OverloadedOrama 2020-06-13 15:30:58 +03:00
parent 8064d7b459
commit a05f8ac4ab

View file

@ -332,7 +332,14 @@ func blend_colors(color_1 : Color, color_2 : Color) -> Color:
# Custom blend rect function, needed because Godot's issue #31124
# The issue has been solved in Godot 3.2.2 and the method will be removed
# once 3.2.2 stable is released
func blend_rect(bg : Image, brush : Image, src_rect : Rect2, dst : Vector2) -> void:
var godot_version = Engine.get_version_info()
if godot_version.major >= 3 and godot_version.minor >= 2 and godot_version.patch >= 2:
bg.blend_rect(brush, src_rect, dst)
return
var brush_size := brush.get_size()
var clipped_src_rect := Rect2(Vector2.ZERO, brush_size).clip(src_rect)
if clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0: