Created
October 17, 2018 13:23
-
-
Save pfirsich/63a9c38e76681947f32886a6a99a32ef to your computer and use it in GitHub Desktop.
love.graphics.setColor compatibility monkeypatch for migrating from love 0.10.2 to 11+
This file contains 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
do | |
local oldSetColor = love.graphics.setColor | |
function love.graphics.setColor(r, g, b, a) | |
if type(r) == "table" then | |
assert(#r == 3 or #r == 4) | |
assert(g == nil and b == nil and a == nil) | |
r, g, b, a = unpack(r) | |
end | |
assert(type(r) == "number" and type(g) == "number" and type(b) == "number") | |
assert(a == nil or type(a) == "number") | |
a = a or 255 | |
oldSetColor(r/255, g/255, b/255, a/255) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment