2020-10-26 17:01:31 +01:00
|
|
|
extends GEAction
|
|
|
|
class_name GEPencil
|
2020-10-25 18:39:10 +01:00
|
|
|
|
|
|
|
|
2020-10-26 17:01:31 +01:00
|
|
|
func do_action(canvas, data: Array):
|
2020-10-27 20:18:11 +01:00
|
|
|
.do_action(canvas, data)
|
2020-10-25 18:39:10 +01:00
|
|
|
|
2020-10-26 20:31:41 +01:00
|
|
|
var pixels = GEUtils.get_pixels_in_line(data[0], data[1])
|
2020-10-26 17:01:31 +01:00
|
|
|
for pixel in pixels:
|
2020-10-30 12:32:04 +01:00
|
|
|
if pixel in action_data.undo.cells or canvas.get_pixel_v(pixel) == null:
|
2020-10-27 20:18:11 +01:00
|
|
|
continue
|
|
|
|
action_data.undo.colors.append(canvas.get_pixel_v(pixel))
|
2020-10-26 17:01:31 +01:00
|
|
|
action_data.undo.cells.append(pixel)
|
2020-10-27 20:18:11 +01:00
|
|
|
canvas.set_pixel_v(pixel, data[2])
|
2020-10-25 18:39:10 +01:00
|
|
|
|
2020-11-02 03:59:25 +01:00
|
|
|
action_data.redo.cells.append(pixel)
|
|
|
|
action_data.redo.colors.append(data[2])
|
2020-10-26 17:01:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
func commit_action(canvas):
|
2020-11-02 03:59:25 +01:00
|
|
|
var cells = action_data.redo.cells
|
|
|
|
var colors = action_data.redo.colors
|
2020-10-27 20:18:11 +01:00
|
|
|
return []
|
2020-10-25 18:39:10 +01:00
|
|
|
|
|
|
|
|
2020-10-26 17:01:31 +01:00
|
|
|
func undo_action(canvas):
|
|
|
|
var cells = action_data.undo.cells
|
|
|
|
var colors = action_data.undo.colors
|
|
|
|
for idx in range(cells.size()):
|
2020-11-02 03:59:25 +01:00
|
|
|
canvas._set_pixel_v(action_data.layer, cells[idx], colors[idx])
|
|
|
|
|
|
|
|
|
|
|
|
func redo_action(canvas):
|
|
|
|
var cells = action_data.redo.cells
|
|
|
|
var colors = action_data.redo.colors
|
|
|
|
for idx in range(cells.size()):
|
|
|
|
canvas._set_pixel_v(action_data.layer, cells[idx], colors[idx])
|
2020-10-25 18:39:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
|