mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-07-14 22:44:43 -04:00
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:
parent
f15578fbe6
commit
64eb4f27ce
3 changed files with 32 additions and 4 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue