1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 09:09:47 +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 := (
rect.position - Vector2i((Vector2(0.5, 0.5) * (_thickness - 1)).ceil())
)
for point in points:
var draw_pos := point + thickness_vector
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(draw_pos):
image.set_pixelv(draw_pos, Color.WHITE)
for i in points.size():
points[i] += thickness_vector
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(points[i]):
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)
canvas.texture = texture
else:

View file

@ -129,12 +129,25 @@ func draw_preview() -> void:
var image := Image.create(
Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_LA8
)
for point in points:
var draw_point := point
for i in points.size():
if Global.mirror_view: # This fixes previewing in mirror mode
draw_point.x = image.get_width() - point.x - 1
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(draw_point):
image.set_pixelv(draw_point, Color.WHITE)
points[i].x = image.get_width() - points[i].x - 1
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(points[i]):
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)
previews.texture = texture

View file

@ -156,6 +156,19 @@ func draw_preview() -> void:
for point in points:
if Rect2i(Vector2i.ZERO, image.get_size()).has_point(point):
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)
canvas.texture = texture
else:

View file

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