diff --git a/src/Classes/Drawers.gd b/src/Classes/Drawers.gd index ab22a44..58eea92 100644 --- a/src/Classes/Drawers.gd +++ b/src/Classes/Drawers.gd @@ -67,13 +67,17 @@ func set_pixel_perfect(value: bool) -> void: func set_pixel(image: Image, position: Vector2, color: Color) -> void: - var mirror_x = Global.current_project.x_max + Global.current_project.x_min - position.x - 1 - var mirror_y = Global.current_project.y_max + Global.current_project.y_min - position.y - 1 + var project : Project = Global.current_project + + var mirror_x = project.size.x - project.x_symmetry_point - position.x + var mirror_y = project.size.y - project.y_symmetry_point - position.y + var mirror_x_inside : bool = mirror_x >= project.x_min and mirror_x <= project.x_max - 1 + var mirror_y_inside : bool = mirror_y >= project.y_min and mirror_y <= project.y_max - 1 drawers[0].set_pixel(image, position, color, color_op) - if horizontal_mirror: + if horizontal_mirror and mirror_x_inside: drawers[1].set_pixel(image, Vector2(mirror_x, position.y), color, color_op) - if vertical_mirror: + if vertical_mirror and mirror_y_inside: drawers[2].set_pixel(image, Vector2(mirror_x, mirror_y), color, color_op) - if vertical_mirror: + if vertical_mirror and mirror_y_inside: drawers[3].set_pixel(image, Vector2(position.x, mirror_y), color, color_op) diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index 71d6744..51faaad 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -16,6 +16,8 @@ var guides := [] # Array of Guides var brushes := [] # Array of Images +var x_symmetry_point := -1 +var y_symmetry_point := -1 var x_min := 0 var x_max := 64 var y_min := 0 diff --git a/src/Tools/Bucket.gd b/src/Tools/Bucket.gd index 0591475..556655e 100644 --- a/src/Tools/Bucket.gd +++ b/src/Tools/Bucket.gd @@ -129,15 +129,17 @@ func fill_in_color(position : Vector2) -> void: func fill_in_area(position : Vector2) -> void: var project : Project = Global.current_project - var mirror_x := project.x_max + project.x_min - position.x - 1 - var mirror_y := project.y_max + project.y_min - position.y - 1 + var mirror_x = project.size.x - project.x_symmetry_point - position.x + var mirror_y = project.size.y - project.y_symmetry_point - position.y + var mirror_x_inside : bool = mirror_x >= project.x_min and mirror_x <= project.x_max - 1 + var mirror_y_inside : bool = mirror_y >= project.y_min and mirror_y <= project.y_max - 1 _flood_fill(position) - if tool_slot.horizontal_mirror: + if tool_slot.horizontal_mirror and mirror_x_inside: _flood_fill(Vector2(mirror_x, position.y)) - if tool_slot.vertical_mirror: + if tool_slot.vertical_mirror and mirror_y_inside: _flood_fill(Vector2(mirror_x, mirror_y)) - if tool_slot.vertical_mirror: + if tool_slot.vertical_mirror and mirror_y_inside: _flood_fill(Vector2(position.x, mirror_y)) diff --git a/src/Tools/Draw.gd b/src/Tools/Draw.gd index 106c070..c4db65b 100644 --- a/src/Tools/Draw.gd +++ b/src/Tools/Draw.gd @@ -268,15 +268,18 @@ func draw_tool_brush(position : Vector2) -> void: var src_rect := Rect2(dst_rect.position - dst, dst_rect.size) dst = dst_rect.position - var mirror_x = draw_rect.end.x + draw_rect.position.x - dst.x - src_rect.size.x - var mirror_y = draw_rect.end.y + draw_rect.position.y - dst.y - src_rect.size.y + var project : Project = Global.current_project + var mirror_x = project.size.x - (project.x_symmetry_point + 1) - dst.x - src_rect.size.x + var mirror_y = project.size.y - (project.y_symmetry_point + 1) - dst.y - src_rect.size.y + var mirror_x_inside : bool = mirror_x >= project.x_min and mirror_x <= project.x_max - 1 + var mirror_y_inside : bool = mirror_y >= project.y_min and mirror_y <= project.y_max - 1 _draw_brush_image(_brush_image, src_rect, dst) - if tool_slot.horizontal_mirror: + if tool_slot.horizontal_mirror and mirror_x_inside: _draw_brush_image(_mirror_brushes.x, _flip_rect(src_rect, size, true, false), Vector2(mirror_x, dst.y)) - if tool_slot.vertical_mirror: + if tool_slot.vertical_mirror and mirror_y_inside: _draw_brush_image(_mirror_brushes.xy, _flip_rect(src_rect, size, true, true), Vector2(mirror_x, mirror_y)) - if tool_slot.vertical_mirror: + if tool_slot.vertical_mirror and mirror_x_inside: _draw_brush_image(_mirror_brushes.y, _flip_rect(src_rect, size, false, true), Vector2(dst.x, mirror_y))