mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 22:10:06 +08:00
fix(color): use math.round instead of floor
This commit is contained in:
parent
b4e860322d
commit
cd08e2430b
@ -78,7 +78,7 @@ color.hsl2rgb = function(h, s, l)
|
|||||||
b = hue2rgb(p, q, h - 1 / 3)
|
b = hue2rgb(p, q, h - 1 / 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
return math.floor(r * 255), math.floor(g * 255), math.floor(b * 255)
|
return math.floor(r * 255 + 0.5), math.floor(g * 255 + 0.5), math.floor(b * 255 + 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- https://www.rapidtables.com/convert/color/rgb-to-hsv.html
|
-- https://www.rapidtables.com/convert/color/rgb-to-hsv.html
|
||||||
@ -136,7 +136,7 @@ color.hsv2rgb = function(h, s, v)
|
|||||||
r, g, b = c, 0, x
|
r, g, b = c, 0, x
|
||||||
end
|
end
|
||||||
r, g, b = (r + m), (g + m), (b + m)
|
r, g, b = (r + m), (g + m), (b + m)
|
||||||
return math.floor(r * 255), math.floor(g * 255), math.floor(b * 255)
|
return math.floor(r * 255 + 0.5), math.floor(g * 255 + 0.5), math.floor(b * 255 + 0.5)
|
||||||
end
|
end
|
||||||
color.hsv2hsl = function(h, s, v)
|
color.hsv2hsl = function(h, s, v)
|
||||||
return color.rgb2hsl(color.hsv2rgb(h, s, v))
|
return color.rgb2hsl(color.hsv2rgb(h, s, v))
|
||||||
|
Loading…
Reference in New Issue
Block a user