mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Correct rectangular and elliptical selection mirroring
This commit is contained in:
parent
d13c5c1063
commit
909f9480cc
|
@ -76,21 +76,22 @@ func apply_selection(_position : Vector2) -> void:
|
||||||
if _rect.size != Vector2.ZERO:
|
if _rect.size != Vector2.ZERO:
|
||||||
var selection_bitmap_copy : BitMap = project.selection_bitmap.duplicate()
|
var selection_bitmap_copy : BitMap = project.selection_bitmap.duplicate()
|
||||||
set_ellipse(selection_bitmap_copy, _rect.position)
|
set_ellipse(selection_bitmap_copy, _rect.position)
|
||||||
|
|
||||||
# Handle mirroring
|
# Handle mirroring
|
||||||
if tool_slot.horizontal_mirror:
|
if tool_slot.horizontal_mirror:
|
||||||
var mirror_x_rect := _rect
|
var mirror_x_rect := _rect
|
||||||
mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x
|
mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x + 1
|
||||||
mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x
|
mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x + 1
|
||||||
set_ellipse(selection_bitmap_copy, mirror_x_rect.abs().position)
|
set_ellipse(selection_bitmap_copy, mirror_x_rect.abs().position)
|
||||||
if tool_slot.vertical_mirror:
|
if tool_slot.vertical_mirror:
|
||||||
var mirror_xy_rect := mirror_x_rect
|
var mirror_xy_rect := mirror_x_rect
|
||||||
mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y
|
mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1
|
||||||
mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y
|
mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1
|
||||||
set_ellipse(selection_bitmap_copy, mirror_xy_rect.abs().position)
|
set_ellipse(selection_bitmap_copy, mirror_xy_rect.abs().position)
|
||||||
if tool_slot.vertical_mirror:
|
if tool_slot.vertical_mirror:
|
||||||
var mirror_y_rect := _rect
|
var mirror_y_rect := _rect
|
||||||
mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y
|
mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1
|
||||||
mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y
|
mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1
|
||||||
set_ellipse(selection_bitmap_copy, mirror_y_rect.abs().position)
|
set_ellipse(selection_bitmap_copy, mirror_y_rect.abs().position)
|
||||||
|
|
||||||
project.selection_bitmap = selection_bitmap_copy
|
project.selection_bitmap = selection_bitmap_copy
|
||||||
|
|
|
@ -61,18 +61,18 @@ func draw_preview() -> void:
|
||||||
# Handle mirroring
|
# Handle mirroring
|
||||||
if tool_slot.horizontal_mirror:
|
if tool_slot.horizontal_mirror:
|
||||||
var mirror_x_rect := _rect
|
var mirror_x_rect := _rect
|
||||||
mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x
|
mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x + 1
|
||||||
mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x
|
mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x + 1
|
||||||
canvas.draw_rect(mirror_x_rect, Color.black, false)
|
canvas.draw_rect(mirror_x_rect, Color.black, false)
|
||||||
if tool_slot.vertical_mirror:
|
if tool_slot.vertical_mirror:
|
||||||
var mirror_xy_rect := mirror_x_rect
|
var mirror_xy_rect := mirror_x_rect
|
||||||
mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y
|
mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1
|
||||||
mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y
|
mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1
|
||||||
canvas.draw_rect(mirror_xy_rect, Color.black, false)
|
canvas.draw_rect(mirror_xy_rect, Color.black, false)
|
||||||
if tool_slot.vertical_mirror:
|
if tool_slot.vertical_mirror:
|
||||||
var mirror_y_rect := _rect
|
var mirror_y_rect := _rect
|
||||||
mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y
|
mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1
|
||||||
mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y
|
mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1
|
||||||
canvas.draw_rect(mirror_y_rect, Color.black, false)
|
canvas.draw_rect(mirror_y_rect, Color.black, false)
|
||||||
canvas.draw_set_transform(canvas.position, canvas.rotation, canvas.scale)
|
canvas.draw_set_transform(canvas.position, canvas.rotation, canvas.scale)
|
||||||
|
|
||||||
|
@ -93,18 +93,18 @@ func apply_selection(_position) -> void:
|
||||||
# Handle mirroring
|
# Handle mirroring
|
||||||
if tool_slot.horizontal_mirror:
|
if tool_slot.horizontal_mirror:
|
||||||
var mirror_x_rect := _rect
|
var mirror_x_rect := _rect
|
||||||
mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x
|
mirror_x_rect.position.x = Global.current_project.x_symmetry_point - _rect.position.x + 1
|
||||||
mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x
|
mirror_x_rect.end.x = Global.current_project.x_symmetry_point - _rect.end.x + 1
|
||||||
Global.canvas.selection.select_rect(mirror_x_rect.abs(), operation)
|
Global.canvas.selection.select_rect(mirror_x_rect.abs(), operation)
|
||||||
if tool_slot.vertical_mirror:
|
if tool_slot.vertical_mirror:
|
||||||
var mirror_xy_rect := mirror_x_rect
|
var mirror_xy_rect := mirror_x_rect
|
||||||
mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y
|
mirror_xy_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1
|
||||||
mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y
|
mirror_xy_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1
|
||||||
Global.canvas.selection.select_rect(mirror_xy_rect.abs(), operation)
|
Global.canvas.selection.select_rect(mirror_xy_rect.abs(), operation)
|
||||||
if tool_slot.vertical_mirror:
|
if tool_slot.vertical_mirror:
|
||||||
var mirror_y_rect := _rect
|
var mirror_y_rect := _rect
|
||||||
mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y
|
mirror_y_rect.position.y = Global.current_project.y_symmetry_point - _rect.position.y + 1
|
||||||
mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y
|
mirror_y_rect.end.y = Global.current_project.y_symmetry_point - _rect.end.y + 1
|
||||||
Global.canvas.selection.select_rect(mirror_y_rect.abs(), operation)
|
Global.canvas.selection.select_rect(mirror_y_rect.abs(), operation)
|
||||||
|
|
||||||
Global.canvas.selection.commit_undo("Rectangle Select", undo_data)
|
Global.canvas.selection.commit_undo("Rectangle Select", undo_data)
|
||||||
|
|
Loading…
Reference in a new issue