4 ms·
The method described at https://drafts.csswg.org/css-color/#css-gamut-mapping https://drafts.csswg.org/css-color/#css-gamut-mapping is equivalent to "Keep light
by jacobolus 2y ago
The method described at https://drafts.csswg.org/css-color/#css-gamut-mapping https://drafts.csswg.org/css-color/#css-gamut-mapping is equivalent to "Keep lightness constant, only compress chroma" from this blog post. They presumably picked that one because it is straightforward and should be good enough for the purpose at hand, which is figuring out what to do when someone puts an out-of-gamut color in their CSS.
The CSS spec doesn't say you have to implement this gamut clipping method via binary search. It's just one possible algorithm that is straightforward to describe so that people can get the intended result with a naïve implementation. Other clipping methods and better algorithms for accomplishing them require significantly more explanation with a bunch of math and color-model-dependent data.
The binary search approach is plenty fast for the CSS use case involving single isolated colors, but would not be appropriate for e.g. adapting photographic images from one output medium to another.