mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-12 16:53:07 +00:00
Compare commits
4 commits
2d28136449
...
aa1731b701
Author | SHA1 | Date | |
---|---|---|---|
|
aa1731b701 | ||
|
558140b309 | ||
|
849b815562 | ||
|
3615ce087c |
|
@ -179,10 +179,14 @@ var can_draw := 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.
|
||||
## (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
|
||||
## (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
|
||||
## 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
|
||||
## Found in Preferences. If [code]true[/code], the last saved project will open on startup.
|
||||
|
|
|
@ -9,9 +9,14 @@ signal options_reset
|
|||
|
||||
enum Dynamics { NONE, PRESSURE, VELOCITY }
|
||||
|
||||
const XY_LINE := Vector2(-0.707107, 0.707107)
|
||||
const X_MINUS_Y_LINE := Vector2(0.707107, 0.707107)
|
||||
|
||||
var picking_color_for := MOUSE_BUTTON_LEFT
|
||||
var horizontal_mirror := false
|
||||
var vertical_mirror := false
|
||||
var diagonal_mirror := false
|
||||
var diagonal_opposite_mirror := false
|
||||
var pixel_perfect := false
|
||||
var alpha_locked := false
|
||||
|
||||
|
@ -524,20 +529,48 @@ func get_mirrored_positions(
|
|||
) -> Array[Vector2i]:
|
||||
var positions: Array[Vector2i] = []
|
||||
if horizontal_mirror:
|
||||
var mirror_x := pos
|
||||
mirror_x.x = project.x_symmetry_point - pos.x + offset
|
||||
var mirror_x := calculate_mirror_horizontal(pos, project, offset)
|
||||
positions.append(mirror_x)
|
||||
if vertical_mirror:
|
||||
var mirror_xy := mirror_x
|
||||
mirror_xy.y = project.y_symmetry_point - pos.y + offset
|
||||
positions.append(mirror_xy)
|
||||
positions.append(calculate_mirror_vertical(mirror_x, project, offset))
|
||||
else:
|
||||
if diagonal_mirror:
|
||||
positions.append(calculate_mirror_xy(mirror_x, project))
|
||||
if diagonal_opposite_mirror:
|
||||
positions.append(calculate_mirror_x_minus_y(mirror_x, project))
|
||||
if vertical_mirror:
|
||||
var mirror_y := pos
|
||||
mirror_y.y = project.y_symmetry_point - pos.y + offset
|
||||
var mirror_y := calculate_mirror_vertical(pos, project, offset)
|
||||
positions.append(mirror_y)
|
||||
if diagonal_mirror:
|
||||
positions.append(calculate_mirror_xy(mirror_y, project))
|
||||
if diagonal_opposite_mirror:
|
||||
positions.append(calculate_mirror_x_minus_y(mirror_y, project))
|
||||
if diagonal_mirror:
|
||||
var mirror_diagonal := calculate_mirror_xy(pos, project)
|
||||
positions.append(mirror_diagonal)
|
||||
if not horizontal_mirror and not vertical_mirror:
|
||||
positions.append(calculate_mirror_x_minus_y(mirror_diagonal, project))
|
||||
if diagonal_opposite_mirror:
|
||||
positions.append(calculate_mirror_x_minus_y(pos, project))
|
||||
return positions
|
||||
|
||||
|
||||
func calculate_mirror_horizontal(pos: Vector2i, project: Project, offset := 0) -> Vector2i:
|
||||
return Vector2i(project.x_symmetry_point - pos.x + offset, pos.y)
|
||||
|
||||
|
||||
func calculate_mirror_vertical(pos: Vector2i, project: Project, offset := 0) -> Vector2i:
|
||||
return Vector2i(pos.x, project.y_symmetry_point - pos.y + offset)
|
||||
|
||||
|
||||
func calculate_mirror_xy(pos: Vector2i, project: Project) -> Vector2i:
|
||||
return Vector2i(Vector2(pos).reflect(XY_LINE).round()) + project.size - Vector2i.ONE
|
||||
|
||||
|
||||
func calculate_mirror_x_minus_y(pos: Vector2i, _project: Project) -> Vector2i:
|
||||
return Vector2i(Vector2(pos).reflect(X_MINUS_Y_LINE).round())
|
||||
|
||||
|
||||
func set_button_size(button_size: int) -> void:
|
||||
var size := Vector2(24, 24) if button_size == Global.ButtonSize.SMALL else Vector2(32, 32)
|
||||
if not is_instance_valid(_tool_buttons):
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
class_name Drawer
|
||||
|
||||
const NUMBER_OF_DRAWERS := 8
|
||||
|
||||
var pixel_perfect := false:
|
||||
set(value):
|
||||
pixel_perfect = value
|
||||
if pixel_perfect:
|
||||
drawers = pixel_perfect_drawers.duplicate()
|
||||
else:
|
||||
drawers = [simple_drawer, simple_drawer, simple_drawer, simple_drawer]
|
||||
_create_simple_drawers()
|
||||
var color_op := ColorOp.new()
|
||||
|
||||
var simple_drawer := SimpleDrawer.new()
|
||||
var pixel_perfect_drawers: Array[PixelPerfectDrawer] = [
|
||||
PixelPerfectDrawer.new(),
|
||||
PixelPerfectDrawer.new(),
|
||||
PixelPerfectDrawer.new(),
|
||||
PixelPerfectDrawer.new()
|
||||
]
|
||||
var drawers := [simple_drawer, simple_drawer, simple_drawer, simple_drawer]
|
||||
var pixel_perfect_drawers: Array[PixelPerfectDrawer] = []
|
||||
var drawers := []
|
||||
|
||||
|
||||
class ColorOp:
|
||||
|
@ -60,6 +57,21 @@ class PixelPerfectDrawer:
|
|||
last_pixels[0] = corner
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
drawers.resize(NUMBER_OF_DRAWERS)
|
||||
pixel_perfect_drawers.resize(NUMBER_OF_DRAWERS)
|
||||
for i in NUMBER_OF_DRAWERS:
|
||||
drawers[i] = simple_drawer
|
||||
pixel_perfect_drawers[i] = PixelPerfectDrawer.new()
|
||||
|
||||
|
||||
func _create_simple_drawers() -> void:
|
||||
drawers = []
|
||||
drawers.resize(NUMBER_OF_DRAWERS)
|
||||
for i in NUMBER_OF_DRAWERS:
|
||||
drawers[i] = simple_drawer
|
||||
|
||||
|
||||
func reset() -> void:
|
||||
for drawer in pixel_perfect_drawers:
|
||||
drawer.reset()
|
||||
|
@ -72,7 +84,12 @@ func set_pixel(image: Image, position: Vector2i, color: Color, ignore_mirroring
|
|||
SteamManager.set_achievement("ACH_FIRST_PIXEL")
|
||||
if ignore_mirroring:
|
||||
return
|
||||
if not Tools.horizontal_mirror and not Tools.vertical_mirror:
|
||||
if (
|
||||
not Tools.horizontal_mirror
|
||||
and not Tools.vertical_mirror
|
||||
and not Tools.diagonal_mirror
|
||||
and not Tools.diagonal_opposite_mirror
|
||||
):
|
||||
return
|
||||
# Handle mirroring
|
||||
var mirrored_positions := Tools.get_mirrored_positions(position, project)
|
||||
|
|
|
@ -71,6 +71,8 @@ var x_symmetry_point: float
|
|||
var y_symmetry_point: float
|
||||
var x_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()
|
||||
## 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
|
||||
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.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)
|
||||
y_symmetry_axis.type = y_symmetry_axis.Types.VERTICAL
|
||||
|
||||
y_symmetry_axis.type = Guide.Types.VERTICAL
|
||||
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))
|
||||
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":
|
||||
export_directory_path = "user://"
|
||||
else:
|
||||
|
|
|
@ -168,18 +168,9 @@ func draw_preview() -> void:
|
|||
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)
|
||||
for point in mirror_array(points):
|
||||
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:
|
||||
|
|
|
@ -205,18 +205,33 @@ func snap_position(pos: Vector2) -> Vector2:
|
|||
return pos
|
||||
|
||||
|
||||
func mirror_array(array: Array[Vector2i], h: bool, v: bool) -> Array[Vector2i]:
|
||||
## Returns an array that mirrors each point of the [param array].
|
||||
## An optional [param callable] can be passed, which gets called for each type of symmetry.
|
||||
func mirror_array(array: Array[Vector2i], callable := func(_array): pass) -> Array[Vector2i]:
|
||||
var new_array: Array[Vector2i] = []
|
||||
var project := Global.current_project
|
||||
for point in array:
|
||||
if h and v:
|
||||
new_array.append(
|
||||
Vector2i(project.x_symmetry_point - point.x, project.y_symmetry_point - point.y)
|
||||
)
|
||||
elif h:
|
||||
new_array.append(Vector2i(project.x_symmetry_point - point.x, point.y))
|
||||
elif v:
|
||||
new_array.append(Vector2i(point.x, project.y_symmetry_point - point.y))
|
||||
if Tools.horizontal_mirror and Tools.vertical_mirror:
|
||||
var hv_array: Array[Vector2i] = []
|
||||
for point in array:
|
||||
var mirror_x := Tools.calculate_mirror_horizontal(point, project)
|
||||
hv_array.append(Tools.calculate_mirror_vertical(mirror_x, project))
|
||||
if callable.is_valid():
|
||||
callable.call(hv_array)
|
||||
new_array += hv_array
|
||||
if Tools.horizontal_mirror:
|
||||
var h_array: Array[Vector2i] = []
|
||||
for point in array:
|
||||
h_array.append(Tools.calculate_mirror_horizontal(point, project))
|
||||
if callable.is_valid():
|
||||
callable.call(h_array)
|
||||
new_array += h_array
|
||||
if Tools.vertical_mirror:
|
||||
var v_array: Array[Vector2i] = []
|
||||
for point in array:
|
||||
v_array.append(Tools.calculate_mirror_vertical(point, project))
|
||||
if callable.is_valid():
|
||||
callable.call(v_array)
|
||||
new_array += v_array
|
||||
|
||||
return new_array
|
||||
|
||||
|
|
|
@ -141,18 +141,9 @@ func draw_preview() -> void:
|
|||
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)
|
||||
for point in mirror_array(points):
|
||||
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
|
||||
|
||||
|
|
|
@ -157,18 +157,9 @@ func draw_preview() -> void:
|
|||
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)
|
||||
for point in mirror_array(points):
|
||||
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:
|
||||
|
|
|
@ -63,18 +63,9 @@ func draw_preview() -> void:
|
|||
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)
|
||||
for point in mirror_array(points):
|
||||
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:
|
||||
|
|
|
@ -46,27 +46,12 @@ func draw_preview() -> void:
|
|||
image.set_pixelv(draw_point, Color.WHITE)
|
||||
|
||||
# Handle mirroring
|
||||
if Tools.horizontal_mirror:
|
||||
for point in mirror_array(_draw_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 Tools.vertical_mirror:
|
||||
for point in mirror_array(_draw_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 Tools.vertical_mirror:
|
||||
for point in mirror_array(_draw_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)
|
||||
for point in mirror_array(_draw_points):
|
||||
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)
|
||||
var texture := ImageTexture.create_from_image(image)
|
||||
canvas.texture = texture
|
||||
else:
|
||||
|
@ -85,19 +70,10 @@ func apply_selection(_position) -> void:
|
|||
if _draw_points.size() > 3:
|
||||
if _intersect:
|
||||
project.selection_map.clear()
|
||||
lasso_selection(project.selection_map, previous_selection_map, _draw_points)
|
||||
|
||||
lasso_selection(_draw_points, project.selection_map, previous_selection_map)
|
||||
# Handle mirroring
|
||||
if Tools.horizontal_mirror:
|
||||
var mirror_x := mirror_array(_draw_points, true, false)
|
||||
lasso_selection(project.selection_map, previous_selection_map, mirror_x)
|
||||
if Tools.vertical_mirror:
|
||||
var mirror_xy := mirror_array(_draw_points, true, true)
|
||||
lasso_selection(project.selection_map, previous_selection_map, mirror_xy)
|
||||
if Tools.vertical_mirror:
|
||||
var mirror_y := mirror_array(_draw_points, false, true)
|
||||
lasso_selection(project.selection_map, previous_selection_map, mirror_y)
|
||||
|
||||
var callable := lasso_selection.bind(project.selection_map, previous_selection_map)
|
||||
mirror_array(_draw_points, callable)
|
||||
Global.canvas.selection.big_bounding_rectangle = project.selection_map.get_used_rect()
|
||||
else:
|
||||
if !cleared:
|
||||
|
@ -109,7 +85,7 @@ func apply_selection(_position) -> void:
|
|||
|
||||
|
||||
func lasso_selection(
|
||||
selection_map: SelectionMap, previous_selection_map: SelectionMap, points: Array[Vector2i]
|
||||
points: Array[Vector2i], selection_map: SelectionMap, previous_selection_map: SelectionMap
|
||||
) -> void:
|
||||
var selection_size := selection_map.get_size()
|
||||
var bounding_rect := Rect2i(points[0], Vector2i.ZERO)
|
||||
|
|
|
@ -74,27 +74,12 @@ func draw_preview() -> void:
|
|||
image.set_pixelv(draw_point, Color.WHITE)
|
||||
|
||||
# Handle mirroring
|
||||
if Tools.horizontal_mirror:
|
||||
for point in mirror_array(_draw_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 Tools.vertical_mirror:
|
||||
for point in mirror_array(_draw_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 Tools.vertical_mirror:
|
||||
for point in mirror_array(_draw_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)
|
||||
for point in mirror_array(_draw_points):
|
||||
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)
|
||||
var texture := ImageTexture.create_from_image(image)
|
||||
canvas.texture = texture
|
||||
else:
|
||||
|
@ -115,18 +100,9 @@ func apply_selection(pos: Vector2i) -> void:
|
|||
if _intersect:
|
||||
project.selection_map.clear()
|
||||
paint_selection(project.selection_map, previous_selection_map, _draw_points)
|
||||
|
||||
# Handle mirroring
|
||||
if Tools.horizontal_mirror:
|
||||
var mirror_x := mirror_array(_draw_points, true, false)
|
||||
paint_selection(project.selection_map, previous_selection_map, mirror_x)
|
||||
if Tools.vertical_mirror:
|
||||
var mirror_xy := mirror_array(_draw_points, true, true)
|
||||
paint_selection(project.selection_map, previous_selection_map, mirror_xy)
|
||||
if Tools.vertical_mirror:
|
||||
var mirror_y := mirror_array(_draw_points, false, true)
|
||||
paint_selection(project.selection_map, previous_selection_map, mirror_y)
|
||||
|
||||
var mirror := mirror_array(_draw_points)
|
||||
paint_selection(project.selection_map, previous_selection_map, mirror)
|
||||
Global.canvas.selection.big_bounding_rectangle = project.selection_map.get_used_rect()
|
||||
else:
|
||||
if !cleared:
|
||||
|
|
|
@ -81,27 +81,12 @@ func draw_preview() -> void:
|
|||
)
|
||||
|
||||
# Handle mirroring
|
||||
if Tools.horizontal_mirror:
|
||||
for point in mirror_array(preview_draw_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 Tools.vertical_mirror:
|
||||
for point in mirror_array(preview_draw_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 Tools.vertical_mirror:
|
||||
for point in mirror_array(preview_draw_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)
|
||||
for point in mirror_array(preview_draw_points):
|
||||
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)
|
||||
var texture := ImageTexture.create_from_image(image)
|
||||
previews.texture = texture
|
||||
else:
|
||||
|
@ -122,19 +107,10 @@ func apply_selection(pos: Vector2i) -> void:
|
|||
if _draw_points.size() > 3:
|
||||
if _intersect:
|
||||
project.selection_map.clear()
|
||||
lasso_selection(project.selection_map, previous_selection_map, _draw_points)
|
||||
|
||||
lasso_selection(_draw_points, project.selection_map, previous_selection_map)
|
||||
# Handle mirroring
|
||||
if Tools.horizontal_mirror:
|
||||
var mirror_x := mirror_array(_draw_points, true, false)
|
||||
lasso_selection(project.selection_map, previous_selection_map, mirror_x)
|
||||
if Tools.vertical_mirror:
|
||||
var mirror_xy := mirror_array(_draw_points, true, true)
|
||||
lasso_selection(project.selection_map, previous_selection_map, mirror_xy)
|
||||
if Tools.vertical_mirror:
|
||||
var mirror_y := mirror_array(_draw_points, false, true)
|
||||
lasso_selection(project.selection_map, previous_selection_map, mirror_y)
|
||||
|
||||
var callable := lasso_selection.bind(project.selection_map, previous_selection_map)
|
||||
mirror_array(_draw_points, callable)
|
||||
Global.canvas.selection.big_bounding_rectangle = project.selection_map.get_used_rect()
|
||||
else:
|
||||
if !cleared:
|
||||
|
@ -152,7 +128,7 @@ func _clear() -> void:
|
|||
|
||||
|
||||
func lasso_selection(
|
||||
selection_map: SelectionMap, previous_selection_map: SelectionMap, points: Array[Vector2i]
|
||||
points: Array[Vector2i], selection_map: SelectionMap, previous_selection_map: SelectionMap
|
||||
) -> void:
|
||||
var selection_size := selection_map.get_size()
|
||||
var bounding_rect := Rect2i(points[0], Vector2i.ZERO)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class_name Guide
|
||||
extends Line2D
|
||||
|
||||
enum Types { HORIZONTAL, VERTICAL }
|
||||
enum Types { HORIZONTAL, VERTICAL, XY, X_MINUS_Y }
|
||||
|
||||
const INPUT_WIDTH := 4
|
||||
|
||||
|
@ -221,14 +221,22 @@ func set_color(color: Color) -> void:
|
|||
default_color = color
|
||||
|
||||
|
||||
func get_direction() -> Vector2:
|
||||
return points[0].direction_to(points[1])
|
||||
|
||||
|
||||
func _project_switched() -> void:
|
||||
if self in Global.current_project.guides:
|
||||
visible = Global.show_guides
|
||||
if self is SymmetryGuide:
|
||||
if type == Types.HORIZONTAL:
|
||||
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
|
||||
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:
|
||||
visible = false
|
||||
|
||||
|
|
|
@ -835,8 +835,12 @@ func _toggle_show_guides() -> void:
|
|||
if guide is SymmetryGuide:
|
||||
if guide.type == Guide.Types.HORIZONTAL:
|
||||
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
|
||||
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:
|
||||
|
|
Loading…
Reference in a new issue