Weird love.graphics.line behaviour
Posted: Wed Jul 20, 2011 11:42 am
Code: Select all
function love.load()
love.graphics.setMode(500, 500)
love.graphics.setLineWidth(100000)
------------------------
-- EDIT THIS VARIABLE --
interval = 1
-- Try out: .9, 1, 2, 5, 10, 50
------------------------
end
function love.draw()
love.graphics.setLine(25)
drawRainbow({255, 0, 0, 255}, 10)
drawRainbow({255, 127, 0, 255}, 20)
drawRainbow({127, 255, 0, 255}, 30)
drawRainbow({ 0, 255, 0, 255}, 40)
drawRainbow({ 0, 255, 127, 255}, 50)
drawRainbow({ 0, 127, 255, 255}, 60)
drawRainbow({ 0, 0, 255, 255}, 70)
drawRainbow({127, 0, 255, 255}, 80)
drawRainbow({255, 0, 127, 255}, 90)
end
local function f(x)
return 250+10*math.sin(x)
end
function drawRainbow(col, offset)
love.graphics.setColor(unpack(col))
local ly, t = f(0), love.timer.getTime()
for x = 1, 500, interval do
local y = f(x/30+t) + offset
love.graphics.line(x-1, ly, x, y)
ly = y
end
end
Why is this happening? Have I hit a bug? Or am I just plain dumb?
Also note setLineWidth doesn't seem to affect anything.
Thanks in advance!