Fix colorspec:to_string

This commit is contained in:
Lars Mueller 2021-07-12 16:15:37 +02:00
parent 44a98a7d41
commit 9d50e504fd
2 changed files with 3 additions and 2 deletions

@ -255,9 +255,9 @@ end
--> hex string, omits alpha if possible (if opaque)
function colorspec:to_string()
if self.a == 255 then
return ("%02X02X02X"):format(self.r, self.g, self.b)
return ("%02X%02X%02X"):format(self.r, self.g, self.b)
end
return ("%02X02X02X02X"):format(self.r, self.g, self.b, self.a)
return ("%02X%02X%02X%02X"):format(self.r, self.g, self.b, self.a)
end
function colorspec:to_number()

@ -267,6 +267,7 @@ test_from_string("aliceblue#42", 0xf0f8ff42)
test_from_string("#333", 0x333333FF)
test_from_string("#694269", 0x694269FF)
test_from_string("#11223344", 0x11223344)
assert(colorspec.from_string"#694269":to_string() == "694269")
local function test_logfile(reference_strings)
local logfile = persistence.lua_log_file.new(mod.get_resource"logfile.test.lua", {}, reference_strings)