Skip to content

Commit

Permalink
Underflow re-check
Browse files Browse the repository at this point in the history
caused by allowing lines in negative directions
  • Loading branch information
SwissalpS committed Jan 13, 2025
1 parent e544e56 commit 5b519ce
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gpu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,16 @@ local function runcommand(pos, meta, command)
local length = 1 + vector.distance(p1, p2)
local dir = vector.direction(p1, p2)
local point
-- not the most eficient process for horizontal, vertical
-- or 45 degree lines
-- Not the most efficient process for horizontal, vertical
-- or 45 degree lines.
for i = 0, length, 0.3 do
point = vector.add(p1, vector.multiply(dir, i))
point = vector.floor(point)
-- Underflow check needed so we don't need more complicated code to
-- calculate dir in negative direction. Overflows are already capped
-- by initiation.
if 1 > point.x then point.x = 1 end
if 1 > point.y then point.y = 1 end
if command.antialias then
buffer[point.y][point.x] = blend(
buffer[point.y][point.x], color, "average")
Expand Down

0 comments on commit 5b519ce

Please sign in to comment.