Skip to content

Instantly share code, notes, and snippets.

@pcornier
Last active May 4, 2018 06:11
Show Gist options
  • Select an option

  • Save pcornier/c4936752648791213cbdeed0a405cd71 to your computer and use it in GitHub Desktop.

Select an option

Save pcornier/c4936752648791213cbdeed0a405cd71 to your computer and use it in GitHub Desktop.
Love2d v11 color compatibility adapter
local major, minor, revision, codename = love.getVersion()
local color = love.graphics.setColor
love.graphics.setColor = function(r, g, b, a)
if type(r) == 'table' then r, g, b, a = unpack(r) end
a = a or 1
if r <= 1 and g <= 1 and b <= 1 and a <= 1 then
if major >= 11 then
color(r, g, b, a)
else
color(255 * r, 255 * g, 255 * b, 255 * a)
end
else
if major >= 11 then
color(r/255, g/255, b/255, a/255)
else
color(r, g, b, a)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment