Last active
May 4, 2018 06:11
-
-
Save pcornier/c4936752648791213cbdeed0a405cd71 to your computer and use it in GitHub Desktop.
Love2d v11 color compatibility adapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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