mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-09 05:21:49 +02:00
Ported PasteCutAction.
This commit is contained in:
parent
aa5a29444a
commit
ad3a5aa196
@ -35,36 +35,50 @@ SOFTWARE.
|
|||||||
void PasteCutAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void PasteCutAction::do_action(PaintCanvas *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
/*
|
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
||||||
.do_action(canvas, data)
|
Vector2i cut_pos = data[4];
|
||||||
|
Vector2i cut_size = data[5];
|
||||||
|
|
||||||
for pixel_pos in GEUtils.get_pixels_in_line(data[0], data[1]):
|
for (int i = 0; i < pixels.size(); ++i) {
|
||||||
for idx in range(data[2].size()):
|
Vector2i pixel_pos = pixels[i];
|
||||||
var pixel = data[2][idx]
|
|
||||||
var color = data[3][idx]
|
|
||||||
pixel -= data[4] + data[5] / 2
|
|
||||||
pixel += pixel_pos
|
|
||||||
|
|
||||||
if canvas.get_pixel_v(pixel) == null:
|
PoolVector2iArray cells = data[2];
|
||||||
continue
|
PoolColorArray colors = data[3];
|
||||||
|
|
||||||
if canvas.is_alpha_locked() and canvas.get_pixel_v(pixel) == Color.transparent:
|
for (int idx = 0; idx < cells.size(); ++idx) {
|
||||||
continue
|
Vector2i pixel = cells[idx];
|
||||||
|
Color color = colors[idx];
|
||||||
|
pixel -= cut_pos + cut_size / 2;
|
||||||
|
pixel += pixel_pos;
|
||||||
|
|
||||||
var found = action_data.redo.cells.find(pixel)
|
if (canvas->validate_pixel_v(pixel)) {
|
||||||
if found == -1:
|
continue;
|
||||||
action_data.redo.cells.append(pixel)
|
}
|
||||||
action_data.redo.colors.append(color)
|
|
||||||
else:
|
|
||||||
action_data.redo.colors[found] = color
|
|
||||||
|
|
||||||
found = action_data.undo.cells.find(pixel)
|
Color col = canvas->get_pixel_v(pixel);
|
||||||
if found == -1:
|
|
||||||
action_data.undo.colors.append(canvas.get_pixel_v(pixel))
|
|
||||||
action_data.undo.cells.append(pixel)
|
|
||||||
|
|
||||||
canvas.set_pixel_v(pixel, color)
|
if (canvas->is_alpha_locked() && col.a < 0.0001) {
|
||||||
*/
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int found = redo_cells.find(pixel);
|
||||||
|
if (found == -1) {
|
||||||
|
redo_cells.push_back(pixel);
|
||||||
|
redo_colors.push_back(color);
|
||||||
|
} else {
|
||||||
|
redo_colors[found] = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
found = undo_cells.find(pixel);
|
||||||
|
|
||||||
|
if (found == -1) {
|
||||||
|
undo_colors.append(col);
|
||||||
|
undo_cells.append(pixel);
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas->set_pixel_v(pixel, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PasteCutAction::PasteCutAction() {
|
PasteCutAction::PasteCutAction() {
|
||||||
|
Loading…
Reference in New Issue
Block a user