Ported DarkenAction.

This commit is contained in:
Relintai 2022-06-20 22:57:44 +02:00
parent 3db7c40a46
commit 61a8942070

View File

@ -31,33 +31,35 @@ SOFTWARE.
void DarkenAction::do_action(PaintCanvas *canvas, const Array &data) { void DarkenAction::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)
var pixels = GEUtils.get_pixels_in_line(data[0], data[1]) for (int i = 0; i < pixels.size(); ++i) {
for pixel in pixels: Vector2i pixel = pixels[i];
if canvas.get_pixel_v(pixel) == null:
continue
if canvas.is_alpha_locked() and canvas.get_pixel_v(pixel) == Color.transparent: if (!canvas->validate_pixel_v(pixel)) {
continue continue;
}
if pixel in action_data.undo.cells: Color col = canvas->get_pixel_v(pixel);
var darkened_color = canvas.get_pixel_v(pixel).darkened(dark_factor)
canvas.set_pixel_v(pixel, darkened_color)
action_data.redo.cells.append(pixel) if (canvas->is_alpha_locked() && col.a < 0.001) {
action_data.redo.colors.append(darkened_color) continue;
continue }
action_data.undo.colors.append(canvas.get_pixel_v(pixel)) Color darkened_color = col.darkened(dark_factor);
action_data.undo.cells.append(pixel)
var darkened_color = canvas.get_pixel_v(pixel).darkened(dark_factor)
canvas.set_pixel_v(pixel, darkened_color)
action_data.redo.cells.append(pixel) canvas->set_pixel_v(pixel, darkened_color);
action_data.redo.colors.append(darkened_color)
*/ redo_cells.append(pixel);
redo_colors.append(darkened_color);
if (undo_cells.contains(pixel)) {
continue;
}
undo_colors.append(col);
undo_cells.append(pixel);
}
} }
DarkenAction::DarkenAction() { DarkenAction::DarkenAction() {