Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gui/design] Update Line & Freeform tools to not overcount tiles #1274

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions internal/design/shapes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,10 @@ function Line:plot_bresenham(x0, y0, x1, y1, thickness)
while true do
for j = -math.floor(thickness / 2), math.ceil(thickness / 2) - 1 do
if not self.arr[x + j] then self.arr[x + j] = {} end
self.arr[x + j][y] = true
self.num_tiles = self.num_tiles + 1
if not self.arr[x + j][y] then
self.arr[x + j][y] = true
self.num_tiles = self.num_tiles + 1
end
end

if x == x1 and y == y1 + i then
Expand Down Expand Up @@ -641,8 +643,10 @@ function FreeForm:update(points, extra_points)
for x, y_row in pairs(line_class.arr) do
for y, _ in pairs(y_row) do
if not self.arr[x] then self.arr[x] = {} end
self.arr[x][y] = true
self.num_tiles = self.num_tiles + 1
if not self.arr[x][y] then
self.arr[x][y] = true
self.num_tiles = self.num_tiles + 1
end
end
end
end
Expand Down