commit: 18aba1ebbc8904e0b39e8a386fb14df672401ce2
parent a00792a7750256ff5b95c0692d3ffce81219962f
Author: Henry Jameson <me@hjkos.com>
Date: Tue, 31 Dec 2024 13:31:37 +0200
clamp value
Diffstat:
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git a/src/services/color_convert/color_convert.js b/src/services/color_convert/color_convert.js
@@ -212,6 +212,7 @@ export const getTextColor = function (bg, text, preserve) {
const multiplier = 10
while (contrast < 4.5 && result.l > 20 && result.l < 80) {
result.l += delta * multiplier
+ result.l = Math.min(100, Math.max(0, result.l))
contrast = getContrastRatio(bg, convert(result).rgb)
console.log(convert(result).hex, result.l, contrast)
}