From 5535d1f9a1272c7107bb55834ee504f11026b6c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 2 Oct 2024 14:56:57 -0700 Subject: [PATCH] Fix srgb to linear (#2372) Co-authored-by: Natalie Weizenbaum --- CHANGELOG.md | 3 +++ lib/src/value/color/space/utils.dart | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b63c0500f..9e1d2b5eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ selector, regardless of which selector they came from. Previously, this reordering only applied to pseudo-selectors in the second selector. +* Fix a slight inaccuracy case when converting to `srgb-linear` and + `display-p3`. + ### JS API * Fix `SassColor.interpolate()` to allow an undefined `options` parameter, as diff --git a/lib/src/value/color/space/utils.dart b/lib/src/value/color/space/utils.dart index d5ecf2eb4..a5be17e22 100644 --- a/lib/src/value/color/space/utils.dart +++ b/lib/src/value/color/space/utils.dart @@ -52,7 +52,7 @@ double hueToRgb(double m1, double m2, double hue) { double srgbAndDisplayP3ToLinear(double channel) { // Algorithm from https://www.w3.org/TR/css-color-4/#color-conversion-code var abs = channel.abs(); - return abs < 0.04045 + return abs <= 0.04045 ? channel / 12.92 : channel.sign * math.pow((abs + 0.055) / 1.055, 2.4); }