1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-30 23:19:49 +00:00

Mirror the previews of the shape tools

Now they are consistent with the selection tools
This commit is contained in:
Emmanouil Papadeas 2024-07-31 22:23:50 +03:00
parent 8e90271a64
commit 8ba2b62921
4 changed files with 57 additions and 28 deletions

View file

@ -163,10 +163,23 @@ func draw_preview() -> void:
var thickness_vector := ( var thickness_vector := (
rect.position - Vector2i((Vector2(0.5, 0.5) * (_thickness - 1)).ceil()) rect.position - Vector2i((Vector2(0.5, 0.5) * (_thickness - 1)).ceil())
) )
for point in points: for i in points.size():
var draw_pos := point + thickness_vector points[i] += thickness_vector
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(draw_pos): if Rect2i(Vector2i.ZERO, image.get_size()).has_point(points[i]):
image.set_pixelv(draw_pos, Color.WHITE) image.set_pixelv(points[i], Color.WHITE)
# Handle mirroring
if Tools.horizontal_mirror:
for point in mirror_array(points, true, false):
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
image.set_pixelv(point, Color.WHITE)
if Tools.vertical_mirror:
for point in mirror_array(points, true, true):
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
image.set_pixelv(point, Color.WHITE)
if Tools.vertical_mirror:
for point in mirror_array(points, false, true):
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
image.set_pixelv(point, Color.WHITE)
var texture := ImageTexture.create_from_image(image) var texture := ImageTexture.create_from_image(image)
canvas.texture = texture canvas.texture = texture
else: else:

View file

@ -129,12 +129,25 @@ func draw_preview() -> void:
var image := Image.create( var image := Image.create(
Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_LA8 Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_LA8
) )
for point in points: for i in points.size():
var draw_point := point
if Global.mirror_view: # This fixes previewing in mirror mode if Global.mirror_view: # This fixes previewing in mirror mode
draw_point.x = image.get_width() - point.x - 1 points[i].x = image.get_width() - points[i].x - 1
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(draw_point): if Rect2i(Vector2i.ZERO, image.get_size()).has_point(points[i]):
image.set_pixelv(draw_point, Color.WHITE) image.set_pixelv(points[i], Color.WHITE)
# Handle mirroring
if Tools.horizontal_mirror:
for point in mirror_array(points, true, false):
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
image.set_pixelv(point, Color.WHITE)
if Tools.vertical_mirror:
for point in mirror_array(points, true, true):
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
image.set_pixelv(point, Color.WHITE)
if Tools.vertical_mirror:
for point in mirror_array(points, false, true):
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
image.set_pixelv(point, Color.WHITE)
var texture := ImageTexture.create_from_image(image) var texture := ImageTexture.create_from_image(image)
previews.texture = texture previews.texture = texture

View file

@ -156,6 +156,19 @@ func draw_preview() -> void:
for point in points: for point in points:
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point): if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
image.set_pixelv(point, Color.WHITE) image.set_pixelv(point, Color.WHITE)
# Handle mirroring
if Tools.horizontal_mirror:
for point in mirror_array(points, true, false):
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
image.set_pixelv(point, Color.WHITE)
if Tools.vertical_mirror:
for point in mirror_array(points, true, true):
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
image.set_pixelv(point, Color.WHITE)
if Tools.vertical_mirror:
for point in mirror_array(points, false, true):
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
image.set_pixelv(point, Color.WHITE)
var texture := ImageTexture.create_from_image(image) var texture := ImageTexture.create_from_image(image)
canvas.texture = texture canvas.texture = texture
else: else:

View file

@ -58,33 +58,23 @@ func draw_preview() -> void:
) )
for i in points.size(): for i in points.size():
points[i] += temp_rect.position points[i] += temp_rect.position
var draw_point := points[i]
if Global.mirror_view: # This fixes previewing in mirror mode if Global.mirror_view: # This fixes previewing in mirror mode
draw_point.x = image.get_width() - draw_point.x - 1 points[i].x = image.get_width() - points[i].x - 1
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(draw_point): if Rect2i(Vector2i.ZERO, image.get_size()).has_point(points[i]):
image.set_pixelv(draw_point, Color.WHITE) image.set_pixelv(points[i], Color.WHITE)
# Handle mirroring # Handle mirroring
if Tools.horizontal_mirror: if Tools.horizontal_mirror:
for point in mirror_array(points, true, false): for point in mirror_array(points, true, false):
var draw_point := point if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
if Global.mirror_view: # This fixes previewing in mirror mode image.set_pixelv(point, Color.WHITE)
draw_point.x = image.get_width() - draw_point.x - 1
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(draw_point):
image.set_pixelv(draw_point, Color.WHITE)
if Tools.vertical_mirror: if Tools.vertical_mirror:
for point in mirror_array(points, true, true): for point in mirror_array(points, true, true):
var draw_point := point if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
if Global.mirror_view: # This fixes previewing in mirror mode image.set_pixelv(point, Color.WHITE)
draw_point.x = image.get_width() - draw_point.x - 1
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(draw_point):
image.set_pixelv(draw_point, Color.WHITE)
if Tools.vertical_mirror: if Tools.vertical_mirror:
for point in mirror_array(points, false, true): for point in mirror_array(points, false, true):
var draw_point := point if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
if Global.mirror_view: # This fixes previewing in mirror mode image.set_pixelv(point, Color.WHITE)
draw_point.x = image.get_width() - draw_point.x - 1
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(draw_point):
image.set_pixelv(draw_point, Color.WHITE)
var texture := ImageTexture.create_from_image(image) var texture := ImageTexture.create_from_image(image)
canvas.texture = texture canvas.texture = texture
else: else: