mirror of
https://github.com/neovim/neovim.git
synced 2026-05-23 21:30:11 +00:00
fix(lsp): fix threshold to compute contrast color #39504
Problem: The threshold to consider a color as bright is too high, and for some colors the foreground is set to white when it should be black. Solution: Change the threshold to 0.179. This value is taken from pastel-textcolor.
This commit is contained in:
@@ -45,7 +45,7 @@ local function get_contrast_color(color)
|
||||
-- Source: https://www.w3.org/TR/WCAG21/#dfn-relative-luminance
|
||||
-- Using power 2.2 is a close approximation to full piecewise transform
|
||||
local R, G, B = (r / 255) ^ 2.2, (g / 255) ^ 2.2, (b / 255) ^ 2.2
|
||||
local is_bright = (0.2126 * R + 0.7152 * G + 0.0722 * B) > 0.5
|
||||
local is_bright = (0.2126 * R + 0.7152 * G + 0.0722 * B) > 0.179
|
||||
return is_bright and '#000000' or '#ffffff'
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user