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

Initial work on diagonal symmetry guides

Still no buttons yet, and they cannot be moved yet.
This commit is contained in:
Emmanouil Papadeas 2024-11-21 04:00:40 +02:00
parent 558140b309
commit aa1731b701
4 changed files with 38 additions and 7 deletions

View file

@ -179,10 +179,14 @@ var can_draw := true
var move_guides_on_canvas := true var move_guides_on_canvas := true
var play_only_tags := true ## If [code]true[/code], animation plays only on frames of the same tag. var play_only_tags := true ## If [code]true[/code], animation plays only on frames of the same tag.
## (Intended to be used as getter only) Tells if the x-symmetry guide ( -- ) is visible. ## If true, the x symmetry guide ( -- ) is visible.
var show_x_symmetry_axis := false var show_x_symmetry_axis := false
## (Intended to be used as getter only) Tells if the y-symmetry guide ( | ) is visible. ## If true, the y symmetry guide ( | ) is visible.
var show_y_symmetry_axis := false var show_y_symmetry_axis := false
## If true, the x=y symmetry guide ( / ) is visible.
var show_x_y_symmetry_axis := false
## If true, the x==y symmetry guide ( \ ) is visible.
var show_x_minus_y_symmetry_axis := false
# Preferences # Preferences
## Found in Preferences. If [code]true[/code], the last saved project will open on startup. ## Found in Preferences. If [code]true[/code], the last saved project will open on startup.

View file

@ -71,6 +71,8 @@ var x_symmetry_point: float
var y_symmetry_point: float var y_symmetry_point: float
var x_symmetry_axis := SymmetryGuide.new() var x_symmetry_axis := SymmetryGuide.new()
var y_symmetry_axis := SymmetryGuide.new() var y_symmetry_axis := SymmetryGuide.new()
var diagonal_xy_symmetry_axis := SymmetryGuide.new()
var diagonal_x_minus_y_symmetry_axis := SymmetryGuide.new()
var selection_map := SelectionMap.new() var selection_map := SelectionMap.new()
## This is useful for when the selection is outside of the canvas boundaries, ## This is useful for when the selection is outside of the canvas boundaries,
@ -111,17 +113,30 @@ func _init(_frames: Array[Frame] = [], _name := tr("untitled"), _size := Vector2
x_symmetry_point = size.x - 1 x_symmetry_point = size.x - 1
y_symmetry_point = size.y - 1 y_symmetry_point = size.y - 1
x_symmetry_axis.type = x_symmetry_axis.Types.HORIZONTAL x_symmetry_axis.type = Guide.Types.HORIZONTAL
x_symmetry_axis.project = self x_symmetry_axis.project = self
x_symmetry_axis.add_point(Vector2(-19999, y_symmetry_point / 2 + 0.5)) x_symmetry_axis.add_point(Vector2(-19999, y_symmetry_point / 2 + 0.5))
x_symmetry_axis.add_point(Vector2(19999, y_symmetry_point / 2 + 0.5)) x_symmetry_axis.add_point(Vector2(19999, y_symmetry_point / 2 + 0.5))
Global.canvas.add_child(x_symmetry_axis) Global.canvas.add_child(x_symmetry_axis)
y_symmetry_axis.type = y_symmetry_axis.Types.VERTICAL
y_symmetry_axis.type = Guide.Types.VERTICAL
y_symmetry_axis.project = self y_symmetry_axis.project = self
y_symmetry_axis.add_point(Vector2(x_symmetry_point / 2 + 0.5, -19999)) y_symmetry_axis.add_point(Vector2(x_symmetry_point / 2 + 0.5, -19999))
y_symmetry_axis.add_point(Vector2(x_symmetry_point / 2 + 0.5, 19999)) y_symmetry_axis.add_point(Vector2(x_symmetry_point / 2 + 0.5, 19999))
Global.canvas.add_child(y_symmetry_axis) Global.canvas.add_child(y_symmetry_axis)
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)
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))
Global.canvas.add_child(diagonal_x_minus_y_symmetry_axis)
if OS.get_name() == "Web": if OS.get_name() == "Web":
export_directory_path = "user://" export_directory_path = "user://"
else: else:

View file

@ -1,7 +1,7 @@
class_name Guide class_name Guide
extends Line2D extends Line2D
enum Types { HORIZONTAL, VERTICAL } enum Types { HORIZONTAL, VERTICAL, XY, X_MINUS_Y }
const INPUT_WIDTH := 4 const INPUT_WIDTH := 4
@ -221,14 +221,22 @@ func set_color(color: Color) -> void:
default_color = color default_color = color
func get_direction() -> Vector2:
return points[0].direction_to(points[1])
func _project_switched() -> void: func _project_switched() -> void:
if self in Global.current_project.guides: if self in Global.current_project.guides:
visible = Global.show_guides visible = Global.show_guides
if self is SymmetryGuide: if self is SymmetryGuide:
if type == Types.HORIZONTAL: if type == Types.HORIZONTAL:
visible = Global.show_x_symmetry_axis and Global.show_guides visible = Global.show_x_symmetry_axis and Global.show_guides
else: elif type == Types.VERTICAL:
visible = Global.show_y_symmetry_axis and Global.show_guides visible = Global.show_y_symmetry_axis and Global.show_guides
elif type == Types.XY:
visible = Global.show_x_y_symmetry_axis and Global.show_guides
elif type == Types.X_MINUS_Y:
visible = Global.show_x_minus_y_symmetry_axis and Global.show_guides
else: else:
visible = false visible = false

View file

@ -835,8 +835,12 @@ func _toggle_show_guides() -> void:
if guide is SymmetryGuide: if guide is SymmetryGuide:
if guide.type == Guide.Types.HORIZONTAL: if guide.type == Guide.Types.HORIZONTAL:
guide.visible = Global.show_x_symmetry_axis and Global.show_guides guide.visible = Global.show_x_symmetry_axis and Global.show_guides
else: elif guide.type == Guide.Types.VERTICAL:
guide.visible = Global.show_y_symmetry_axis and Global.show_guides guide.visible = Global.show_y_symmetry_axis and Global.show_guides
elif guide.type == Guide.Types.XY:
guide.visible = Global.show_x_y_symmetry_axis and Global.show_guides
elif guide.type == Guide.Types.X_MINUS_Y:
guide.visible = Global.show_x_minus_y_symmetry_axis and Global.show_guides
func _toggle_show_mouse_guides() -> void: func _toggle_show_mouse_guides() -> void: