Friday, April 1, 2022

Vim Color Schemes

function! IsHexColorLight(color) abort

let l:raw_color = trim(a:color, '#')


let l:red = str2nr(substitute(l:raw_color, '(.{2}).{4}', '1', 'g'), 16)

let l:green = str2nr(substitute(l:raw_color, '.{2}(.{2}).{2}', '1', 'g'), 16)

let l:blue = str2nr(substitute(l:raw_color, '.{4}(.{2})', '1', 'g'), 16)


let l:brightness = ((l:red * 299) + (l:green * 587) + (l:blue * 114)) / 1000


return l:brightness > 155

endfunction



from Hacker News https://ift.tt/Knpt2L0

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.