clamp value
This commit is contained in:
parent
a00792a775
commit
18aba1ebbc
1 changed files with 1 additions and 0 deletions
|
@ -212,6 +212,7 @@ export const getTextColor = function (bg, text, preserve) {
|
||||||
const multiplier = 10
|
const multiplier = 10
|
||||||
while (contrast < 4.5 && result.l > 20 && result.l < 80) {
|
while (contrast < 4.5 && result.l > 20 && result.l < 80) {
|
||||||
result.l += delta * multiplier
|
result.l += delta * multiplier
|
||||||
|
result.l = Math.min(100, Math.max(0, result.l))
|
||||||
contrast = getContrastRatio(bg, convert(result).rgb)
|
contrast = getContrastRatio(bg, convert(result).rgb)
|
||||||
console.log(convert(result).hex, result.l, contrast)
|
console.log(convert(result).hex, result.l, contrast)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue