Code: Select all
local inp = 1 / 42
love.graphics.setColor(inp, inp, inp)
local outp = love.graphics.getColor()
print(inp, outp)
Code: Select all
0.023809523809524 0.023809524253011
Code: Select all
local inp = 1 / 42
love.graphics.setColor(inp, inp, inp)
local outp = love.graphics.getColor()
print(inp, outp)
Code: Select all
0.023809523809524 0.023809524253011
Code: Select all
local int8 = {}
for i=0,255 do int8[i] = i/255 end
Code: Select all
local lg = love.graphics
local oldSetColor = lg.setColor
local oldGetColor = lg.getColor
local oldReset = lg.reset
local def = {1, 1, 1, 1}
local color = def
lg.setColor = function(...)
color = {...}
oldSetColor(...)
end
lg.getColor = function()
return unpack(color)
end
lg.reset = function()
color = def
oldReset()
end
Code: Select all
require 'colors'
local inp = 1 / 42
love.graphics.setColor(inp, inp, inp)
local outp = love.graphics.getColor()
print(inp, outp)
Code: Select all
0.023809523809524 0.023809523809524
Code: Select all
local lg = love.graphics
local c1 = 0.1
lg.setColor(c1,c1,c1)
local c2,_,_,_ = lg.getColor()
assert(c1 == c2) -- assertion failed
Code: Select all
local function d2f(n)
return n - n%0.0000001 -- positive numbers only
end
function love.graphics.getColor2()
local r,g,b,a = love.graphics.getColor()
return d2f(r),d2f(g),d2f(b),d2f(a)
end
Code: Select all
local ffi = require 'ffi'
print(tonumber(ffi.cast('float', 0.1))) -- prints 0.10000000149012
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 3 guests