|
|
@ -13,6 +13,11 @@ var is_pasting := false
|
|
|
|
var big_bounding_rectangle := Rect2i():
|
|
|
|
var big_bounding_rectangle := Rect2i():
|
|
|
|
set(value):
|
|
|
|
set(value):
|
|
|
|
big_bounding_rectangle = value
|
|
|
|
big_bounding_rectangle = value
|
|
|
|
|
|
|
|
if value.size == Vector2i(0, 0):
|
|
|
|
|
|
|
|
set_process_input(false)
|
|
|
|
|
|
|
|
Global.can_draw = true
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
set_process_input(true)
|
|
|
|
for slot in Tools._slots.values():
|
|
|
|
for slot in Tools._slots.values():
|
|
|
|
if slot.tool_node is BaseSelectionTool:
|
|
|
|
if slot.tool_node is BaseSelectionTool:
|
|
|
|
slot.tool_node.set_spinbox_values()
|
|
|
|
slot.tool_node.set_spinbox_values()
|
|
|
@ -34,7 +39,8 @@ var preview_image_texture := ImageTexture.new()
|
|
|
|
var undo_data: Dictionary
|
|
|
|
var undo_data: Dictionary
|
|
|
|
var gizmos: Array[Gizmo] = []
|
|
|
|
var gizmos: Array[Gizmo] = []
|
|
|
|
var dragged_gizmo: Gizmo = null
|
|
|
|
var dragged_gizmo: Gizmo = null
|
|
|
|
var prev_angle := 0
|
|
|
|
var angle := 0.0
|
|
|
|
|
|
|
|
var content_pivot := Vector2.ZERO
|
|
|
|
var mouse_pos_on_gizmo_drag := Vector2.ZERO
|
|
|
|
var mouse_pos_on_gizmo_drag := Vector2.ZERO
|
|
|
|
var resize_keep_ratio := false
|
|
|
|
var resize_keep_ratio := false
|
|
|
|
|
|
|
|
|
|
|
@ -53,24 +59,24 @@ class Gizmo:
|
|
|
|
type = _type
|
|
|
|
type = _type
|
|
|
|
direction = _direction
|
|
|
|
direction = _direction
|
|
|
|
|
|
|
|
|
|
|
|
func get_cursor() -> Control.CursorShape:
|
|
|
|
func get_cursor() -> DisplayServer.CursorShape:
|
|
|
|
var cursor := Control.CURSOR_MOVE
|
|
|
|
var cursor := DisplayServer.CURSOR_MOVE
|
|
|
|
if direction == Vector2i.ZERO:
|
|
|
|
if direction == Vector2i.ZERO:
|
|
|
|
return Control.CURSOR_POINTING_HAND
|
|
|
|
return DisplayServer.CURSOR_POINTING_HAND
|
|
|
|
elif direction == Vector2i(-1, -1) or direction == Vector2i(1, 1): # Top left or bottom right
|
|
|
|
elif direction == Vector2i(-1, -1) or direction == Vector2i(1, 1): # Top left or bottom right
|
|
|
|
if Global.mirror_view:
|
|
|
|
if Global.mirror_view:
|
|
|
|
cursor = Control.CURSOR_BDIAGSIZE
|
|
|
|
cursor = DisplayServer.CURSOR_BDIAGSIZE
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
cursor = Control.CURSOR_FDIAGSIZE
|
|
|
|
cursor = DisplayServer.CURSOR_FDIAGSIZE
|
|
|
|
elif direction == Vector2i(1, -1) or direction == Vector2i(-1, 1): # Top right or bottom left
|
|
|
|
elif direction == Vector2i(1, -1) or direction == Vector2i(-1, 1): # Top right or bottom left
|
|
|
|
if Global.mirror_view:
|
|
|
|
if Global.mirror_view:
|
|
|
|
cursor = Control.CURSOR_FDIAGSIZE
|
|
|
|
cursor = DisplayServer.CURSOR_FDIAGSIZE
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
cursor = Control.CURSOR_BDIAGSIZE
|
|
|
|
cursor = DisplayServer.CURSOR_BDIAGSIZE
|
|
|
|
elif direction == Vector2i(0, -1) or direction == Vector2i(0, 1): # Center top or center bottom
|
|
|
|
elif direction == Vector2i(0, -1) or direction == Vector2i(0, 1): # Center top or center bottom
|
|
|
|
cursor = Control.CURSOR_VSIZE
|
|
|
|
cursor = DisplayServer.CURSOR_VSIZE
|
|
|
|
elif direction == Vector2i(-1, 0) or direction == Vector2i(1, 0): # Center left or center right
|
|
|
|
elif direction == Vector2i(-1, 0) or direction == Vector2i(1, 0): # Center left or center right
|
|
|
|
cursor = Control.CURSOR_HSIZE
|
|
|
|
cursor = DisplayServer.CURSOR_HSIZE
|
|
|
|
return cursor
|
|
|
|
return cursor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -84,12 +90,11 @@ func _ready() -> void:
|
|
|
|
gizmos.append(Gizmo.new(Gizmo.Type.SCALE, Vector2i(0, 1))) # Center bottom
|
|
|
|
gizmos.append(Gizmo.new(Gizmo.Type.SCALE, Vector2i(0, 1))) # Center bottom
|
|
|
|
gizmos.append(Gizmo.new(Gizmo.Type.SCALE, Vector2i(-1, 1))) # Bottom left
|
|
|
|
gizmos.append(Gizmo.new(Gizmo.Type.SCALE, Vector2i(-1, 1))) # Bottom left
|
|
|
|
gizmos.append(Gizmo.new(Gizmo.Type.SCALE, Vector2i(-1, 0))) # Center left
|
|
|
|
gizmos.append(Gizmo.new(Gizmo.Type.SCALE, Vector2i(-1, 0))) # Center left
|
|
|
|
|
|
|
|
#gizmos.append(Gizmo.new(Gizmo.Type.ROTATE)) # Rotation gizmo (temp)
|
|
|
|
|
|
|
|
|
|
|
|
# gizmos.append(Gizmo.new(Gizmo.Type.ROTATE)) # Rotation gizmo (temp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
|
|
|
|
|
|
var project := Global.current_project
|
|
|
|
image_current_pixel = canvas.current_pixel
|
|
|
|
image_current_pixel = canvas.current_pixel
|
|
|
|
if Global.mirror_view:
|
|
|
|
if Global.mirror_view:
|
|
|
|
image_current_pixel.x = Global.current_project.size.x - image_current_pixel.x
|
|
|
|
image_current_pixel.x = Global.current_project.size.x - image_current_pixel.x
|
|
|
@ -99,7 +104,6 @@ func _input(event: InputEvent) -> void:
|
|
|
|
elif Input.is_action_just_pressed("transformation_cancel"):
|
|
|
|
elif Input.is_action_just_pressed("transformation_cancel"):
|
|
|
|
transform_content_cancel()
|
|
|
|
transform_content_cancel()
|
|
|
|
|
|
|
|
|
|
|
|
var project := Global.current_project
|
|
|
|
|
|
|
|
if not project.layers[project.current_layer].can_layer_get_drawn():
|
|
|
|
if not project.layers[project.current_layer].can_layer_get_drawn():
|
|
|
|
return
|
|
|
|
return
|
|
|
|
if event is InputEventKey:
|
|
|
|
if event is InputEventKey:
|
|
|
@ -123,17 +127,14 @@ func _input(event: InputEvent) -> void:
|
|
|
|
if Input.is_action_pressed("transform_move_selection_only"):
|
|
|
|
if Input.is_action_pressed("transform_move_selection_only"):
|
|
|
|
transform_content_confirm()
|
|
|
|
transform_content_confirm()
|
|
|
|
if not is_moving_content:
|
|
|
|
if not is_moving_content:
|
|
|
|
|
|
|
|
original_bitmap.copy_from(Global.current_project.selection_map)
|
|
|
|
|
|
|
|
original_big_bounding_rectangle = big_bounding_rectangle
|
|
|
|
if Input.is_action_pressed("transform_move_selection_only"):
|
|
|
|
if Input.is_action_pressed("transform_move_selection_only"):
|
|
|
|
undo_data = get_undo_data(false)
|
|
|
|
undo_data = get_undo_data(false)
|
|
|
|
temp_rect = big_bounding_rectangle
|
|
|
|
temp_rect = big_bounding_rectangle
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
transform_content_start()
|
|
|
|
transform_content_start()
|
|
|
|
project.selection_offset = Vector2.ZERO
|
|
|
|
project.selection_offset = Vector2.ZERO
|
|
|
|
if dragged_gizmo.type == Gizmo.Type.ROTATE:
|
|
|
|
|
|
|
|
var img_size := maxi(
|
|
|
|
|
|
|
|
original_preview_image.get_width(), original_preview_image.get_height()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
original_preview_image.crop(img_size, img_size)
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
var prev_temp_rect := temp_rect
|
|
|
|
var prev_temp_rect := temp_rect
|
|
|
|
dragged_gizmo.direction.x *= signi(temp_rect.size.x)
|
|
|
|
dragged_gizmo.direction.x *= signi(temp_rect.size.x)
|
|
|
@ -157,7 +158,9 @@ func _input(event: InputEvent) -> void:
|
|
|
|
Global.can_draw = true
|
|
|
|
Global.can_draw = true
|
|
|
|
dragged_gizmo = null
|
|
|
|
dragged_gizmo = null
|
|
|
|
if not is_moving_content:
|
|
|
|
if not is_moving_content:
|
|
|
|
|
|
|
|
original_bitmap = SelectionMap.new()
|
|
|
|
commit_undo("Select", undo_data)
|
|
|
|
commit_undo("Select", undo_data)
|
|
|
|
|
|
|
|
angle = 0.0
|
|
|
|
|
|
|
|
|
|
|
|
if dragged_gizmo:
|
|
|
|
if dragged_gizmo:
|
|
|
|
if dragged_gizmo.type == Gizmo.Type.SCALE:
|
|
|
|
if dragged_gizmo.type == Gizmo.Type.SCALE:
|
|
|
@ -166,17 +169,17 @@ func _input(event: InputEvent) -> void:
|
|
|
|
_gizmo_rotate()
|
|
|
|
_gizmo_rotate()
|
|
|
|
else: # Set the appropriate cursor
|
|
|
|
else: # Set the appropriate cursor
|
|
|
|
if gizmo_hover:
|
|
|
|
if gizmo_hover:
|
|
|
|
Global.main_viewport.mouse_default_cursor_shape = gizmo_hover.get_cursor()
|
|
|
|
DisplayServer.cursor_set_shape(gizmo_hover.get_cursor())
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
var cursor := Control.CURSOR_ARROW
|
|
|
|
var cursor := DisplayServer.CURSOR_ARROW
|
|
|
|
if Global.cross_cursor:
|
|
|
|
if Global.cross_cursor:
|
|
|
|
cursor = Control.CURSOR_CROSS
|
|
|
|
cursor = DisplayServer.CURSOR_CROSS
|
|
|
|
var layer: BaseLayer = project.layers[project.current_layer]
|
|
|
|
var layer: BaseLayer = project.layers[project.current_layer]
|
|
|
|
if not layer.can_layer_get_drawn():
|
|
|
|
if not layer.can_layer_get_drawn():
|
|
|
|
cursor = Control.CURSOR_FORBIDDEN
|
|
|
|
cursor = DisplayServer.CURSOR_FORBIDDEN
|
|
|
|
|
|
|
|
|
|
|
|
if Global.main_viewport.mouse_default_cursor_shape != cursor:
|
|
|
|
if DisplayServer.cursor_get_shape() != cursor:
|
|
|
|
Global.main_viewport.mouse_default_cursor_shape = cursor
|
|
|
|
DisplayServer.cursor_set_shape(cursor)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _move_with_arrow_keys(event: InputEvent) -> void:
|
|
|
|
func _move_with_arrow_keys(event: InputEvent) -> void:
|
|
|
@ -210,14 +213,14 @@ func _move_with_arrow_keys(event: InputEvent) -> void:
|
|
|
|
var move := input.rotated(snappedf(Global.camera.rotation, PI / 2))
|
|
|
|
var move := input.rotated(snappedf(Global.camera.rotation, PI / 2))
|
|
|
|
# These checks are needed to fix a bug where the selection got stuck
|
|
|
|
# These checks are needed to fix a bug where the selection got stuck
|
|
|
|
# to the canvas boundaries when they were 1px away from them
|
|
|
|
# to the canvas boundaries when they were 1px away from them
|
|
|
|
if is_equal_approx(absf(move.x), 0.0):
|
|
|
|
if is_zero_approx(absf(move.x)):
|
|
|
|
move.x = 0
|
|
|
|
move.x = 0
|
|
|
|
if is_equal_approx(absf(move.y), 0.0):
|
|
|
|
if is_zero_approx(absf(move.y)):
|
|
|
|
move.y = 0
|
|
|
|
move.y = 0
|
|
|
|
move_content(move * step)
|
|
|
|
move_content(move * step)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check if an event is a ui_up/down/left/right event-press
|
|
|
|
## Check if an event is a ui_up/down/left/right event pressed
|
|
|
|
func _is_action_direction_pressed(event: InputEvent) -> bool:
|
|
|
|
func _is_action_direction_pressed(event: InputEvent) -> bool:
|
|
|
|
for action in KEY_MOVE_ACTION_NAMES:
|
|
|
|
for action in KEY_MOVE_ACTION_NAMES:
|
|
|
|
if event.is_action_pressed(action, false, true):
|
|
|
|
if event.is_action_pressed(action, false, true):
|
|
|
@ -225,7 +228,7 @@ func _is_action_direction_pressed(event: InputEvent) -> bool:
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check if an event is a ui_up/down/left/right event release
|
|
|
|
## Check if an event is a ui_up/down/left/right event
|
|
|
|
func _is_action_direction(event: InputEvent) -> bool:
|
|
|
|
func _is_action_direction(event: InputEvent) -> bool:
|
|
|
|
for action in KEY_MOVE_ACTION_NAMES:
|
|
|
|
for action in KEY_MOVE_ACTION_NAMES:
|
|
|
|
if event.is_action(action, true):
|
|
|
|
if event.is_action(action, true):
|
|
|
@ -233,7 +236,7 @@ func _is_action_direction(event: InputEvent) -> bool:
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check if an event is a ui_up/down/left/right event release
|
|
|
|
## Check if an event is a ui_up/down/left/right event release
|
|
|
|
func _is_action_direction_released(event: InputEvent) -> bool:
|
|
|
|
func _is_action_direction_released(event: InputEvent) -> bool:
|
|
|
|
for action in KEY_MOVE_ACTION_NAMES:
|
|
|
|
for action in KEY_MOVE_ACTION_NAMES:
|
|
|
|
if event.is_action_released(action, true):
|
|
|
|
if event.is_action_released(action, true):
|
|
|
@ -282,9 +285,9 @@ func _update_gizmos() -> void:
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Rotation gizmo (temp)
|
|
|
|
# Rotation gizmo (temp)
|
|
|
|
# gizmos[8].rect = Rect2(
|
|
|
|
#gizmos[8].rect = Rect2(
|
|
|
|
# Vector2((rect_end.x + rect_pos.x - size.x) / 2, rect_pos.y - size.y - (size.y * 2)), size
|
|
|
|
#Vector2((rect_end.x + rect_pos.x - size.x) / 2, rect_pos.y - size.y - (size.y * 2)), size
|
|
|
|
# )
|
|
|
|
#)
|
|
|
|
queue_redraw()
|
|
|
|
queue_redraw()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -337,8 +340,6 @@ func _gizmo_resize() -> void:
|
|
|
|
temp_rect.position.y = end_y - temp_rect.size.y
|
|
|
|
temp_rect.position.y = end_y - temp_rect.size.y
|
|
|
|
|
|
|
|
|
|
|
|
big_bounding_rectangle = temp_rect.abs()
|
|
|
|
big_bounding_rectangle = temp_rect.abs()
|
|
|
|
# big_bounding_rectangle.position = Vector2(big_bounding_rectangle.position).ceil()
|
|
|
|
|
|
|
|
# big_bounding_rectangle.size = big_bounding_rectangle.size.floor()
|
|
|
|
|
|
|
|
if big_bounding_rectangle.size.x == 0:
|
|
|
|
if big_bounding_rectangle.size.x == 0:
|
|
|
|
big_bounding_rectangle.size.x = 1
|
|
|
|
big_bounding_rectangle.size.x = 1
|
|
|
|
if big_bounding_rectangle.size.y == 0:
|
|
|
|
if big_bounding_rectangle.size.y == 0:
|
|
|
@ -370,9 +371,14 @@ func _resize_rect(pos: Vector2, dir: Vector2) -> void:
|
|
|
|
|
|
|
|
|
|
|
|
func resize_selection() -> void:
|
|
|
|
func resize_selection() -> void:
|
|
|
|
var size := big_bounding_rectangle.size.abs()
|
|
|
|
var size := big_bounding_rectangle.size.abs()
|
|
|
|
if is_moving_content:
|
|
|
|
if original_bitmap.is_empty():
|
|
|
|
|
|
|
|
print("original_bitmap is empty, this shouldn't happen.")
|
|
|
|
|
|
|
|
else:
|
|
|
|
Global.current_project.selection_map.copy_from(original_bitmap)
|
|
|
|
Global.current_project.selection_map.copy_from(original_bitmap)
|
|
|
|
|
|
|
|
if is_moving_content:
|
|
|
|
|
|
|
|
content_pivot = original_big_bounding_rectangle.size / 2.0
|
|
|
|
preview_image.copy_from(original_preview_image)
|
|
|
|
preview_image.copy_from(original_preview_image)
|
|
|
|
|
|
|
|
DrawingAlgos.nn_rotate(preview_image, angle, content_pivot)
|
|
|
|
preview_image.resize(size.x, size.y, Image.INTERPOLATE_NEAREST)
|
|
|
|
preview_image.resize(size.x, size.y, Image.INTERPOLATE_NEAREST)
|
|
|
|
if temp_rect.size.x < 0:
|
|
|
|
if temp_rect.size.x < 0:
|
|
|
|
preview_image.flip_x()
|
|
|
|
preview_image.flip_x()
|
|
|
@ -380,6 +386,12 @@ func resize_selection() -> void:
|
|
|
|
preview_image.flip_y()
|
|
|
|
preview_image.flip_y()
|
|
|
|
preview_image_texture = ImageTexture.create_from_image(preview_image)
|
|
|
|
preview_image_texture = ImageTexture.create_from_image(preview_image)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Global.current_project.selection_map.copy_from(original_bitmap)
|
|
|
|
|
|
|
|
var bitmap_pivot := (
|
|
|
|
|
|
|
|
original_big_bounding_rectangle.position
|
|
|
|
|
|
|
|
+ ((original_big_bounding_rectangle.end - original_big_bounding_rectangle.position) / 2)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
DrawingAlgos.nn_rotate(Global.current_project.selection_map, angle, bitmap_pivot)
|
|
|
|
Global.current_project.selection_map.resize_bitmap_values(
|
|
|
|
Global.current_project.selection_map.resize_bitmap_values(
|
|
|
|
Global.current_project, size, temp_rect.size.x < 0, temp_rect.size.y < 0
|
|
|
|
Global.current_project, size, temp_rect.size.x < 0, temp_rect.size.y < 0
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -388,40 +400,12 @@ func resize_selection() -> void:
|
|
|
|
Global.canvas.queue_redraw()
|
|
|
|
Global.canvas.queue_redraw()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _gizmo_rotate() -> void: ## Currently unused, as it does not work properly yet
|
|
|
|
func _gizmo_rotate() -> void:
|
|
|
|
var angle := image_current_pixel.angle_to_point(mouse_pos_on_gizmo_drag)
|
|
|
|
angle = image_current_pixel.angle_to_point(mouse_pos_on_gizmo_drag)
|
|
|
|
angle = deg_to_rad(floorf(rad_to_deg(angle)))
|
|
|
|
resize_selection()
|
|
|
|
if angle == prev_angle:
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
prev_angle = angle
|
|
|
|
|
|
|
|
var pivot := Vector2(big_bounding_rectangle.size.x / 2.0, big_bounding_rectangle.size.y / 2.0)
|
|
|
|
|
|
|
|
preview_image.copy_from(original_preview_image)
|
|
|
|
|
|
|
|
if original_big_bounding_rectangle.position != big_bounding_rectangle.position:
|
|
|
|
|
|
|
|
preview_image.fill(Color(0, 0, 0, 0))
|
|
|
|
|
|
|
|
var pos_diff := (
|
|
|
|
|
|
|
|
(original_big_bounding_rectangle.position - big_bounding_rectangle.position).abs()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
preview_image.blit_rect(
|
|
|
|
|
|
|
|
original_preview_image, Rect2(Vector2.ZERO, preview_image.get_size()), pos_diff
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
DrawingAlgos.nn_rotate(preview_image, angle, pivot)
|
|
|
|
|
|
|
|
preview_image_texture = ImageTexture.create_from_image(preview_image)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var bitmap_image := SelectionMap.new()
|
|
|
|
|
|
|
|
bitmap_image.copy_from(original_bitmap)
|
|
|
|
|
|
|
|
var bitmap_pivot := (
|
|
|
|
|
|
|
|
original_big_bounding_rectangle.position
|
|
|
|
|
|
|
|
+ ((original_big_bounding_rectangle.end - original_big_bounding_rectangle.position) / 2)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
DrawingAlgos.nn_rotate(bitmap_image, angle, bitmap_pivot)
|
|
|
|
|
|
|
|
Global.current_project.selection_map.copy_from(bitmap_image)
|
|
|
|
|
|
|
|
Global.current_project.selection_map_changed()
|
|
|
|
|
|
|
|
big_bounding_rectangle = Global.current_project.selection_map.get_used_rect()
|
|
|
|
|
|
|
|
queue_redraw()
|
|
|
|
|
|
|
|
Global.canvas.queue_redraw()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func select_rect(rect: Rect2i, operation: int = SelectionOperation.ADD) -> void:
|
|
|
|
func select_rect(rect: Rect2i, operation := SelectionOperation.ADD) -> void:
|
|
|
|
var project := Global.current_project
|
|
|
|
var project := Global.current_project
|
|
|
|
# Used only if the selection is outside of the canvas boundaries,
|
|
|
|
# Used only if the selection is outside of the canvas boundaries,
|
|
|
|
# on the left and/or above (negative coords)
|
|
|
|
# on the left and/or above (negative coords)
|
|
|
@ -508,15 +492,15 @@ func transform_content_confirm() -> void:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
var project := Global.current_project
|
|
|
|
var project := Global.current_project
|
|
|
|
for cel in _get_selected_draw_cels():
|
|
|
|
for cel in _get_selected_draw_cels():
|
|
|
|
var cel_image: Image = cel.get_image()
|
|
|
|
var cel_image := cel.get_image()
|
|
|
|
var src: Image = preview_image
|
|
|
|
var src := Image.new()
|
|
|
|
|
|
|
|
src.copy_from(preview_image)
|
|
|
|
if not is_pasting:
|
|
|
|
if not is_pasting:
|
|
|
|
src.copy_from(cel.transformed_content)
|
|
|
|
src.copy_from(cel.transformed_content)
|
|
|
|
cel.transformed_content = null
|
|
|
|
cel.transformed_content = null
|
|
|
|
|
|
|
|
DrawingAlgos.nn_rotate(src, angle, content_pivot)
|
|
|
|
src.resize(
|
|
|
|
src.resize(
|
|
|
|
big_bounding_rectangle.size.x,
|
|
|
|
preview_image.get_width(), preview_image.get_height(), Image.INTERPOLATE_NEAREST
|
|
|
|
big_bounding_rectangle.size.y,
|
|
|
|
|
|
|
|
Image.INTERPOLATE_NEAREST
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if temp_rect.size.x < 0:
|
|
|
|
if temp_rect.size.x < 0:
|
|
|
|
src.flip_x()
|
|
|
|
src.flip_x()
|
|
|
@ -537,6 +521,8 @@ func transform_content_confirm() -> void:
|
|
|
|
original_bitmap = SelectionMap.new()
|
|
|
|
original_bitmap = SelectionMap.new()
|
|
|
|
is_moving_content = false
|
|
|
|
is_moving_content = false
|
|
|
|
is_pasting = false
|
|
|
|
is_pasting = false
|
|
|
|
|
|
|
|
angle = 0.0
|
|
|
|
|
|
|
|
content_pivot = Vector2.ZERO
|
|
|
|
queue_redraw()
|
|
|
|
queue_redraw()
|
|
|
|
Global.canvas.queue_redraw()
|
|
|
|
Global.canvas.queue_redraw()
|
|
|
|
|
|
|
|
|
|
|
@ -568,6 +554,8 @@ func transform_content_cancel() -> void:
|
|
|
|
preview_image = Image.new()
|
|
|
|
preview_image = Image.new()
|
|
|
|
original_bitmap = SelectionMap.new()
|
|
|
|
original_bitmap = SelectionMap.new()
|
|
|
|
is_pasting = false
|
|
|
|
is_pasting = false
|
|
|
|
|
|
|
|
angle = 0.0
|
|
|
|
|
|
|
|
content_pivot = Vector2.ZERO
|
|
|
|
queue_redraw()
|
|
|
|
queue_redraw()
|
|
|
|
Global.canvas.queue_redraw()
|
|
|
|
Global.canvas.queue_redraw()
|
|
|
|
|
|
|
|
|
|
|
|