Fixed BrushAction.

This commit is contained in:
Relintai 2022-06-20 01:47:20 +02:00
parent 5f683261ff
commit b2d2a6fbe5
2 changed files with 8 additions and 5 deletions

View File

@ -34,7 +34,9 @@ void BrushAction::do_action(PaintCanvas *canvas, const Array &data) {
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]); PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
int brush_type = data[3]; int brush_type = data[3];
PoolVector2iArray brush = BrushPrefabs::get_brush(static_cast<BrushPrefabs::Type>(brush_type), data[4]); int brush_size = data[4];
PoolVector2iArray brush = BrushPrefabs::get_brush(static_cast<BrushPrefabs::Type>(brush_type), brush_size);
Color tcolor = data[2];
for (int i = 0; i < pixels.size(); ++i) { for (int i = 0; i < pixels.size(); ++i) {
Vector2i pixel = pixels[i]; Vector2i pixel = pixels[i];
@ -56,10 +58,10 @@ void BrushAction::do_action(PaintCanvas *canvas, const Array &data) {
undo_colors.append(col); undo_colors.append(col);
undo_cells.append(p); undo_cells.append(p);
canvas->set_pixel_v(pixel, data[2]); canvas->set_pixel_v(p, tcolor);
redo_cells.append(p); redo_cells.append(p);
redo_colors.append(data[2]); redo_colors.append(tcolor);
} }
} }
} }

View File

@ -23,6 +23,7 @@ SOFTWARE.
*/ */
#include "bush_prefabs.h" #include "bush_prefabs.h"
#include "core/print_string.h"
/* /*
const list = [ const list = [
@ -55,12 +56,12 @@ PoolVector2iArray BrushPrefabs::get_brush(const BrushPrefabs::Type type, int siz
case CIRCLE: { case CIRCLE: {
size += 1; size += 1;
Vector2 center; Vector2 center;
int radius = size / 2.0; float radius = size / 2.0;
for (int x = 0; x < size; ++x) { for (int x = 0; x < size; ++x) {
for (int y = 0; y < size; ++y) { for (int y = 0; y < size; ++y) {
if (Vector2(x - radius, y - radius).length() < size / 3.0) { if (Vector2(x - radius, y - radius).length() < size / 3.0) {
pixels.append(Vector2(x, y)); pixels.append(Vector2i(x, y));
} }
} }
} }