Skip to content

Instantly share code, notes, and snippets.

@mustooch
Last active July 18, 2019 16:10
Show Gist options
  • Save mustooch/909c63da9d9ef1df7a50ede3eaadacd1 to your computer and use it in GitHub Desktop.
Save mustooch/909c63da9d9ef1df7a50ede3eaadacd1 to your computer and use it in GitHub Desktop.
Display current time with the hex color format in the background
function hex_time()
time = os.date("*t", os.time())
return {time.hour, time.min, time.sec}
end
function hex2dec(n)
return tonumber("0x"..n)
end
function hex2love(t)
return {
hex2dec(t[1])/255,
hex2dec(t[2])/255,
hex2dec(t[3])/255
}
end
function love.load()
hex_str = ""
love.window.setMode(512,512)
end
function love.update(dt)
time = hex_time()
hex_str = "#"..tostring(time[1])..tostring(time[2])..tostring(time[3])
back = hex2love(time)
love.graphics.setBackgroundColor(back[1],back[2],back[3])
end
function love.draw()
love.graphics.print(hex_str, 512/2-20, 512/2)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment