From cfb767346e7879ea021187856a61eedaa1d46f7c Mon Sep 17 00:00:00 2001 From: frozolotl <44589151+frozolotl@users.noreply.github.com> Date: Wed, 8 Nov 2023 20:10:37 +1000 Subject: [PATCH] Fix OkLab color negation (#2609) This changes negation to effectively rotate hue by 180deg. Previously, negation failed in certain cases and produced unexpected results. --- crates/typst/src/geom/color.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/typst/src/geom/color.rs b/crates/typst/src/geom/color.rs index bf04408c..3a02a8c2 100644 --- a/crates/typst/src/geom/color.rs +++ b/crates/typst/src/geom/color.rs @@ -906,7 +906,7 @@ impl Color { pub fn negate(self) -> Color { match self { Self::Luma(c) => Self::Luma(Luma::new(1.0 - c.luma)), - Self::Oklab(c) => Self::Oklab(Oklab::new(c.l, 1.0 - c.a, 1.0 - c.b, c.alpha)), + Self::Oklab(c) => Self::Oklab(Oklab::new(c.l, -c.a, -c.b, c.alpha)), Self::LinearRgb(c) => Self::LinearRgb(LinearRgba::new( 1.0 - c.red, 1.0 - c.green,