mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-05-12 20:34:11 +00:00
Fixed sortCoords for draw functions (#749)
This commit is contained in:
parent
e48427dbbc
commit
9708dd6786
@ -132,7 +132,17 @@ function drawLine(startX, startY, endX, endY, colour)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local minX, maxX, minY, maxY = sortCoords(startX, startY, endX, endY)
|
local minX = math.min(startX, endX)
|
||||||
|
local maxX, minY, maxY
|
||||||
|
if minX == startX then
|
||||||
|
minY = startY
|
||||||
|
maxX = endX
|
||||||
|
maxY = endY
|
||||||
|
else
|
||||||
|
minY = endY
|
||||||
|
maxX = startX
|
||||||
|
maxY = startY
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO: clip to screen rectangle?
|
-- TODO: clip to screen rectangle?
|
||||||
|
|
||||||
|
@ -67,6 +67,19 @@ describe("The paintutils library", function()
|
|||||||
{ " ", "000", "ffe" },
|
{ " ", "000", "ffe" },
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("draws a line going diagonally from bottom left", function()
|
||||||
|
local w = with_window(3, 3, function()
|
||||||
|
term.setBackgroundColour(colours.red)
|
||||||
|
paintutils.drawLine(1, 3, 3, 1)
|
||||||
|
end)
|
||||||
|
|
||||||
|
window_eq(w, {
|
||||||
|
{ " ", "000", "ffe" },
|
||||||
|
{ " ", "000", "fef" },
|
||||||
|
{ " ", "000", "eff" },
|
||||||
|
})
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe("paintutils.drawBox", function()
|
describe("paintutils.drawBox", function()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user