mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-03 22:55:55 +01:00
Ported get_points in PaintAction.
This commit is contained in:
parent
0f97b55f27
commit
f3a3fdfd75
@ -4,21 +4,21 @@ Copyright (c) 2020-2022 cobrapitz
|
|||||||
Copyright (c) 2022 Péter Magyar
|
Copyright (c) 2022 Péter Magyar
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software && associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, && to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The above copyright notice && this permission notice shall be included in all
|
||||||
copies or substantial portions of the Software.
|
copies || substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE && NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS || COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES || OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT || OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF || IN CONNECTION WITH THE SOFTWARE || THE USE || OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -92,44 +92,73 @@ PoolVector2iArray PaintAction::get_xy_sym_points(const int canvas_width, const i
|
|||||||
|
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolVector2iArray PaintAction::get_points(PaintCanvas *canvas, const Vector2i &pixel) {
|
PoolVector2iArray PaintAction::get_points(PaintCanvas *canvas, const Vector2i &pixel) {
|
||||||
/*
|
|
||||||
PoolVector2iArray points;
|
PoolVector2iArray points;
|
||||||
if canvas.symmetry_x and canvas.symmetry_y:
|
|
||||||
var sym_points = get_xy_sym_points(canvas.canvas_width, canvas.canvas_height, pixel)
|
if (canvas->symmetry_x && canvas->symmetry_y) {
|
||||||
for point in sym_points:
|
PoolVector2iArray sym_points = get_xy_sym_points(canvas->get_canvas_width(), canvas->get_canvas_height(), pixel);
|
||||||
if point in action_data.undo.cells or canvas.get_pixel_v(point) == null:
|
|
||||||
continue
|
for (int i = 0; i < sym_points.size(); ++i) {
|
||||||
if canvas.is_alpha_locked() and canvas.get_pixel_v(pixel) == Color.transparent:
|
Vector2i point = sym_points[i];
|
||||||
continue
|
|
||||||
points.append(point)
|
if (undo_cells.contains(point) || !canvas->validate_pixel_v(point)) {
|
||||||
elif canvas.symmetry_y:
|
continue;
|
||||||
var sym_points = get_y_sym_points(canvas.canvas_height, pixel)
|
}
|
||||||
for point in sym_points:
|
|
||||||
if point in action_data.undo.cells or canvas.get_pixel_v(point) == null:
|
if (canvas->is_alpha_locked() && canvas->get_pixel_v(pixel) == Color(0, 0, 0, 0)) {
|
||||||
continue
|
continue;
|
||||||
if canvas.is_alpha_locked() and canvas.get_pixel_v(pixel) == Color.transparent:
|
}
|
||||||
continue
|
|
||||||
points.append(point)
|
points.append(point);
|
||||||
elif canvas.symmetry_x:
|
}
|
||||||
var sym_points = get_x_sym_points(canvas.canvas_width, pixel)
|
} else if (canvas->symmetry_y) {
|
||||||
for point in sym_points:
|
PoolVector2iArray sym_points = get_y_sym_points(canvas->get_canvas_height(), pixel);
|
||||||
if point in action_data.undo.cells or canvas.get_pixel_v(point) == null:
|
|
||||||
continue
|
for (int i = 0; i < sym_points.size(); ++i) {
|
||||||
if canvas.is_alpha_locked() and canvas.get_pixel_v(pixel) == Color.transparent:
|
Vector2i point = sym_points[i];
|
||||||
continue
|
|
||||||
points.append(point)
|
if (undo_cells.contains(point) || !canvas->validate_pixel_v(point)) {
|
||||||
else:
|
continue;
|
||||||
if pixel in action_data.undo.cells or canvas.get_pixel_v(pixel) == null:
|
}
|
||||||
return []
|
|
||||||
if canvas.is_alpha_locked() and canvas.get_pixel_v(pixel) == Color.transparent:
|
if (canvas->is_alpha_locked() && canvas->get_pixel_v(pixel) == Color(0, 0, 0, 0)) {
|
||||||
return []
|
continue;
|
||||||
points.append(pixel)
|
}
|
||||||
|
|
||||||
|
points.append(point);
|
||||||
|
}
|
||||||
|
} else if (canvas->symmetry_x) {
|
||||||
|
PoolVector2iArray sym_points = get_x_sym_points(canvas->get_canvas_width(), pixel);
|
||||||
|
|
||||||
|
for (int i = 0; i < sym_points.size(); ++i) {
|
||||||
|
Vector2i point = sym_points[i];
|
||||||
|
|
||||||
|
if (undo_cells.contains(point) || !canvas->validate_pixel_v(point)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canvas->is_alpha_locked() && canvas->get_pixel_v(pixel) == Color(0, 0, 0, 0)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
points.append(point);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (undo_cells.contains(pixel) || !canvas->validate_pixel_v(pixel)) {
|
||||||
|
//empty
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canvas->is_alpha_locked() && canvas->get_pixel_v(pixel) == Color(0, 0, 0, 0)) {
|
||||||
|
//empty
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
points.append(pixel);
|
||||||
|
}
|
||||||
|
|
||||||
return points;
|
return points;
|
||||||
*/
|
|
||||||
|
|
||||||
return PoolVector2iArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintAction::draw_points(PaintCanvas *canvas, const PoolVector2iArray &point_arr, const PoolColorArray &color_arr) {
|
void PaintAction::draw_points(PaintCanvas *canvas, const PoolVector2iArray &point_arr, const PoolColorArray &color_arr) {
|
||||||
|
@ -432,6 +432,15 @@ Color PaintCanvas::get_preview_pixel(const int x, const int y) {
|
|||||||
|
|
||||||
return preview_layer->get_pixel(x, y);
|
return preview_layer->get_pixel(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PaintCanvas::validate_pixel_v(const Vector2i &pos) const {
|
||||||
|
if (active_layer.is_valid()) {
|
||||||
|
return active_layer->validate_pixel_v(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void PaintCanvas::toggle_grid() {
|
void PaintCanvas::toggle_grid() {
|
||||||
grid->set_visible(!grid->is_visible());
|
grid->set_visible(!grid->is_visible());
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,8 @@ public:
|
|||||||
Color get_preview_pixel_v(const Vector2i &pos);
|
Color get_preview_pixel_v(const Vector2i &pos);
|
||||||
Color get_preview_pixel(const int x, const int y);
|
Color get_preview_pixel(const int x, const int y);
|
||||||
|
|
||||||
|
bool validate_pixel_v(const Vector2i &pos) const;
|
||||||
|
|
||||||
void toggle_grid();
|
void toggle_grid();
|
||||||
void show_grid();
|
void show_grid();
|
||||||
void hide_grid();
|
void hide_grid();
|
||||||
|
@ -100,6 +100,13 @@ Color PaintCanvasLayer::get_pixel(const int x, const int y) {
|
|||||||
|
|
||||||
return pixel;
|
return pixel;
|
||||||
}
|
}
|
||||||
|
bool PaintCanvasLayer::validate_pixel_v(const Vector2i &pos) const {
|
||||||
|
if (pos.x < 0 || pos.y < 0 || pos.x >= image->get_width() || pos.y >= image->get_height()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
void PaintCanvasLayer::clear() {
|
void PaintCanvasLayer::clear() {
|
||||||
//Color.transparent
|
//Color.transparent
|
||||||
image->fill(Color(1.00, 1.00, 1.00, 0.00));
|
image->fill(Color(1.00, 1.00, 1.00, 0.00));
|
||||||
|
@ -56,6 +56,7 @@ public:
|
|||||||
void resize(const int width, const int height);
|
void resize(const int width, const int height);
|
||||||
void set_pixel(const int x, const int y, const Color &color);
|
void set_pixel(const int x, const int y, const Color &color);
|
||||||
Color get_pixel(const int x, const int y);
|
Color get_pixel(const int x, const int y);
|
||||||
|
bool validate_pixel_v(const Vector2i &pos) const;
|
||||||
void clear();
|
void clear();
|
||||||
void update_texture();
|
void update_texture();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user