1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Minor drawing optimization

This commit is contained in:
Manolis Papadeas 2021-07-01 18:14:49 +03:00
parent 43bd054df6
commit 9234005d1a
2 changed files with 8 additions and 12 deletions

View file

@ -73,15 +73,10 @@ func set_pixel(image: Image, position: Vector2, color: Color) -> void:
# Handle Mirroring
var mirror_x = project.x_symmetry_point - position.x
var mirror_y = project.y_symmetry_point - position.y
var mirror_x_inside : bool
var mirror_y_inside : bool
mirror_x_inside = project.can_pixel_get_drawn(Vector2(mirror_x, position.y))
mirror_y_inside = project.can_pixel_get_drawn(Vector2(position.x, mirror_y))
if horizontal_mirror and mirror_x_inside:
if horizontal_mirror and project.can_pixel_get_drawn(Vector2(mirror_x, position.y)):
drawers[1].set_pixel(image, Vector2(mirror_x, position.y), color, color_op)
if vertical_mirror and mirror_y_inside:
if vertical_mirror and project.can_pixel_get_drawn(Vector2(position.x, mirror_y)):
drawers[2].set_pixel(image, Vector2(mirror_x, mirror_y), color, color_op)
if vertical_mirror and mirror_y_inside:
if vertical_mirror and project.can_pixel_get_drawn(Vector2(position.x, mirror_y)):
drawers[3].set_pixel(image, Vector2(position.x, mirror_y), color, color_op)

View file

@ -620,11 +620,11 @@ func can_pixel_get_drawn(pixel : Vector2, bitmap : BitMap = selection_bitmap, se
if pixel.x < 0 or pixel.y < 0 or pixel.x >= size.x or pixel.y >= size.y:
return false
if selection_position.x < 0:
pixel.x -= selection_position.x
if selection_position.y < 0:
pixel.y -= selection_position.y
if has_selection:
if selection_position.x < 0:
pixel.x -= selection_position.x
if selection_position.y < 0:
pixel.y -= selection_position.y
return bitmap.get_bit(pixel)
else:
return true
@ -672,6 +672,7 @@ func bitmap_to_image(bitmap : BitMap, square := true) -> Image:
return image
# Algorithm taken from Image.get_used_rect() - https://github.com/godotengine/godot/blob/master/core/io/image.cpp
func get_selection_rectangle(bitmap : BitMap = selection_bitmap) -> Rect2:
if bitmap.get_true_bit_count() == 0:
return Rect2()