You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In certain scenarios, the color components may be negative, leading to the generation of an invalid hex value.
// transform hex to oklchconsthex="#a96800";constcolor=fromHex(newArray(3),hex);// [0.6627450980392157, 0.40784313725490196, 0]constoklch=toOklch(color)as[number,number,number];// [0.575356813769678, 0.12642355966665692, 0.188380147597491]// reverse transform oklch to hex, in this case the color2[2] is already **negative**constcolor2=fromOklch(newArray(3), ...oklch);// [0.6627451073936355, 0.4078431276995599, -3.3454380928166215e-7]// because toHex use Math.round, so it may still gets correct hexconsthex2=toHex(color2);// ✅ "#A96800"// but in some bad case, for example, when precision lost in further processing, the hex value may be wrongconstoklchRounded=[0.58,0.13,0.19]asconst;constcolor3=fromOklch(newArray(3), ...oklchRounded);// [0.671842467563041, 0.41184974144751946, -0.041825356581836816];consthex3=toHex(color3);// ❌ "#B"
The text was updated successfully, but these errors were encountered:
In certain scenarios, the color components may be negative, leading to the generation of an invalid hex value.
The text was updated successfully, but these errors were encountered: