From b0e81d4b3fd2bd525955f1d95145cf62d64ac096 Mon Sep 17 00:00:00 2001 From: frozolotl <44589151+frozolotl@users.noreply.github.com> Date: Fri, 17 Nov 2023 10:41:45 +0100 Subject: Remove restrictions to chroma and improve clamping (#2690) This PR does a few small things: - Oklab's a*/b* and Oklch's chroma components can be as large as desired. - In PDF, when encoding Oklab, the range is widened from [-0.4,0.4] to [-0.5,0.5]. - In PDF, clamping is now performed on Oklch's chroma instead of a* and b*. This causes hue not to be distorted when clamping. SVG and PNG export remain unchanged: - SVG itself never had any restrictions on chroma. We directly use the `oklab` and `oklch` CSS colors, which should work fine for the most part. In the future, embedded ICC profiles might be nice. Further research is likely necessary. - While PNG does not support color spaces like Oklab or Oklch, certain useful features exist. One can define gamma (gAMA) and chromacities&whitepoint (cHRM) chunks and even embed ICC profiles. While `image` crate does not support these features for encoding, its backend crate `png` does support gAMA and cHRM. It does not allow embedding ICC profiles yet, though. As it stands, to fully support wide gamuts and more accurate colors, more work is necessary. This PR should help a bit though. --- tests/typ/compiler/color.typ | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/typ') diff --git a/tests/typ/compiler/color.typ b/tests/typ/compiler/color.typ index 86dd1542..ec1f9902 100644 --- a/tests/typ/compiler/color.typ +++ b/tests/typ/compiler/color.typ @@ -31,6 +31,11 @@ #box(square(size: 9pt, fill: color.hsl(col))) #box(square(size: 9pt, fill: color.hsv(col))) +--- +// Colors outside the sRGB gamut. +#box(square(size: 9pt, fill: oklab(90%, -0.2, -0.1))) +#box(square(size: 9pt, fill: oklch(50%, 0.5, 0deg))) + --- // Test hue rotation #let col = rgb(50%, 64%, 16%) -- cgit v1.2.3