UPDATE:MDN实际上有一个很好的十进制舍入示例,可以避免浮点不精确。根据OP,他们的方法可以修改为总是...
If it’s too dark or too light, increase or decrease the lightness by 0.005 (or 0.5%) and check the luminance again. Once the color’s luminance matches the target, round off the final lightness value to the nearest hundredth (or percentage point). Now that lightness and luminance were a...