Sets the color used for drawing.
In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.
love.graphics.setColor( red, green, blue, alpha )
number rednumber greennumber bluenumber alpha (1)Nothing.
Available since LÖVE 0.7.0
This variant is not supported in earlier versions.
love.graphics.setColor( rgba )
table rgbaNothing.
function love.draw()
love.graphics.setColor(1, 0, 0)
love.graphics.circle("fill", 50, 50, 20)
love.graphics.setColor(0, 0, 1)
love.graphics.circle("fill", 50, 100, 20)
myColor = {0, 1, 0, 1}
love.graphics.setColor(myColor)
love.graphics.circle("fill", 50, 150, 20)
end function love.load()
baseX = 300
baseY = 400
radius = 100
offsetY = radius*.5*math.sqrt(3)
love.graphics.setBackgroundColor(1, 1, 1)
end
function love.draw()
love.graphics.setColor(1, 0, 0, 0.4)
love.graphics.circle('fill', baseX, baseY, radius)
love.graphics.setColor(0, 1, 0, 0.4)
love.graphics.circle('fill', baseX + radius / 2, baseY - offsetY, radius)
love.graphics.setColor(0, 0, 1, 0.4)
love.graphics.circle('fill', baseX + radius, baseY, radius)
end
© 2006–2020 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.graphics.setColor