Skip to content

Commit

Permalink
Fix srgb to linear (#2372)
Browse files Browse the repository at this point in the history
Co-authored-by: Natalie Weizenbaum <nweiz@google.com>
  • Loading branch information
ntkme and nex3 authored Oct 2, 2024
1 parent 5acae8a commit 5535d1f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/src/value/color/space/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5535d1f

Please sign in to comment.