I've fiddled with this code at great length to try and discover what the hell was going on. Switching from points to rectangles, to spacing by 2 (which does seem to reduce the likelihood of the problem), etc. What exactly is going on?
Code: Select all
xSize = 500
ySize = 500
local firstCanvas
local currentCanvas
function love.load()
love.window.setMode(xSize, ySize)
firstCanvas = love.graphics.newCanvas(xSize, ySize)
currentCanvas = firstCanvas
love.graphics.setCanvas(currentCanvas)
white_count = 0
black_count = 0
for i = 10, xSize - 10 do
for j = 10, ySize - 10 do
if love.math.random() < .45 then
white_count = white_count + 1
love.graphics.setColor(255, 255, 255)
love.graphics.rectangle("fill", i, j, 2, 2)
else
black_count = black_count + 1
love.graphics.setColor(0, 0, 0)
love.graphics.rectangle("fill", i, j, 2, 2)
end
end
end
love.graphics.rectangle("fill", 50, 50, 2, 2)
love.graphics.rectangle("fill", 50, 52, 2, 2)
love.graphics.rectangle("fill", 52, 50, 2, 2)
love.graphics.rectangle("fill", 52, 52, 2, 2)
print(white_count .. " " .. black_count)
love.graphics.setCanvas()
love.graphics.draw(currentCanvas)
end
function love.update(dt)
if dt < 1/30 then
love.timer.sleep(1/30 - dt)
end
end
function love.draw()
love.graphics.draw(currentCanvas)
end