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

Center diagonal symmetry guides when initializing a new project

The guides appear centered, but the symmetry itself is not working properly yet
This commit is contained in:
Emmanouil Papadeas 2024-11-21 16:33:19 +02:00
parent 3d65e48c92
commit d0ecf3b03d
3 changed files with 16 additions and 8 deletions

View file

@ -548,7 +548,7 @@ func get_mirrored_positions(
if diagonal_xy_mirror:
var mirror_diagonal := calculate_mirror_xy(pos, project)
positions.append(mirror_diagonal)
if not horizontal_mirror and not vertical_mirror:
if not horizontal_mirror and not vertical_mirror and diagonal_x_minus_y_mirror:
positions.append(calculate_mirror_x_minus_y(mirror_diagonal, project))
if diagonal_x_minus_y_mirror:
positions.append(calculate_mirror_x_minus_y(pos, project))
@ -564,11 +564,14 @@ func calculate_mirror_vertical(pos: Vector2i, project: Project, offset := 0) ->
func calculate_mirror_xy(pos: Vector2i, project: Project) -> Vector2i:
return Vector2i(Vector2(pos).reflect(XY_LINE).round()) + project.size - Vector2i.ONE
return Vector2i(Vector2(pos).reflect(XY_LINE).round()) + Vector2i(project.xy_symmetry_point)
func calculate_mirror_x_minus_y(pos: Vector2i, _project: Project) -> Vector2i:
return Vector2i(Vector2(pos).reflect(X_MINUS_Y_LINE).round())
func calculate_mirror_x_minus_y(pos: Vector2i, project: Project) -> Vector2i:
return (
Vector2i(Vector2(pos).reflect(X_MINUS_Y_LINE).round())
+ Vector2i(project.x_minus_y_symmetry_point)
)
func set_button_size(button_size: int) -> void:

View file

@ -69,6 +69,8 @@ var user_data := "" ## User defined data, set in the project properties.
var x_symmetry_point: float
var y_symmetry_point: float
var xy_symmetry_point: Vector2
var x_minus_y_symmetry_point: Vector2
var x_symmetry_axis := SymmetryGuide.new()
var y_symmetry_axis := SymmetryGuide.new()
var diagonal_xy_symmetry_axis := SymmetryGuide.new()
@ -113,6 +115,8 @@ func _init(_frames: Array[Frame] = [], _name := tr("untitled"), _size := Vector2
x_symmetry_point = size.x - 1
y_symmetry_point = size.y - 1
xy_symmetry_point = Vector2i(size.y, size.x) - Vector2i.ONE
x_minus_y_symmetry_point = Vector2(maxi(size.x - size.y, 0), maxi(size.y - size.x, 0))
x_symmetry_axis.type = Guide.Types.HORIZONTAL
x_symmetry_axis.project = self
x_symmetry_axis.add_point(Vector2(-19999, y_symmetry_point / 2 + 0.5))
@ -128,13 +132,13 @@ func _init(_frames: Array[Frame] = [], _name := tr("untitled"), _size := Vector2
diagonal_xy_symmetry_axis.type = Guide.Types.XY
diagonal_xy_symmetry_axis.project = self
diagonal_xy_symmetry_axis.add_point(Vector2(19999, -19999))
diagonal_xy_symmetry_axis.add_point(Vector2i(-19999, 19999) + size)
diagonal_xy_symmetry_axis.add_point(Vector2(-19999, 19999) + xy_symmetry_point + Vector2.ONE)
Global.canvas.add_child(diagonal_xy_symmetry_axis)
diagonal_x_minus_y_symmetry_axis.type = Guide.Types.X_MINUS_Y
diagonal_x_minus_y_symmetry_axis.project = self
diagonal_x_minus_y_symmetry_axis.add_point(Vector2(-19999, -19999))
diagonal_x_minus_y_symmetry_axis.add_point(Vector2(19999, 19999))
diagonal_x_minus_y_symmetry_axis.add_point(Vector2(19999, 19999) + x_minus_y_symmetry_point)
Global.canvas.add_child(diagonal_x_minus_y_symmetry_axis)
if OS.get_name() == "Web":

View file

@ -31,12 +31,13 @@ func _input(_event: InputEvent) -> void:
if type == Types.HORIZONTAL:
point0.y -= width * INPUT_WIDTH
point1.y += width * INPUT_WIDTH
else:
elif type == Types.VERTICAL:
point0.x -= width * INPUT_WIDTH
point1.x += width * INPUT_WIDTH
var rect := Rect2()
rect.position = point0
rect.end = point1
rect = rect.abs()
if (
Input.is_action_just_pressed(&"left_mouse")
and Global.can_draw
@ -55,7 +56,7 @@ func _input(_event: InputEvent) -> void:
var yy := snappedf(mouse_pos.y, 0.5)
points[0].y = yy
points[1].y = yy
else:
elif type == Types.VERTICAL:
var xx := snappedf(mouse_pos.x, 0.5)
points[0].x = xx
points[1].x = xx