Cut option (#345)

* I Made the cut function, his respective shortcut <c-x> and the appearence of the function in the top
bar in edit.

* Update Main.tscn
This commit is contained in:
PinyaColada 2020-10-08 17:05:33 +02:00 committed by GitHub
parent f15578fbe6
commit 64eb4f27ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 4 deletions

View file

@ -116,6 +116,26 @@ func copy() -> void:
project.brushes.append(brush)
Brushes.add_project_brush(brush)
func cut() -> void: # This is basically the same as copy + delete
if _selected_rect.has_no_area():
return
var undo_data = _get_undo_data(true)
var project := Global.current_project
var image : Image = project.frames[project.current_frame].cels[project.current_layer].image
var size := _selected_rect.size
var rect = Rect2(Vector2.ZERO, size)
_clipboard = image.get_rect(_selected_rect)
if _clipboard.is_invisible():
return
_clear_image.resize(size.x, size.y, Image.INTERPOLATE_NEAREST)
var brush = _clipboard.get_rect(_clipboard.get_used_rect())
project.brushes.append(brush)
Brushes.add_project_brush(brush)
Global.selection_rectangle.move_end() #The selection_rectangle can be used while is moved, this prevents malfunctioning
image.blit_rect(_clear_image, rect, _selected_rect.position)
commit_undo("Draw", undo_data)
func paste() -> void:
if _clipboard.get_size() <= Vector2.ZERO: