diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cdd7f5c3..9ef6274e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 1.98.0 + +* **Potentially breaking CSS compatibility fix:** In keeping with the latest CSS + specification, this release changes the algorithm for converting colors to and + from the `rec2020` color space. This now uses the EOTF algorithm with a gamma + of 2.4. + ## 1.97.3 * Fix a bug where nesting an at-rule within multiple style rules in plain CSS diff --git a/lib/src/value/color/space/rec2020.dart b/lib/src/value/color/space/rec2020.dart index 822fb2359..f983114bc 100644 --- a/lib/src/value/color/space/rec2020.dart +++ b/lib/src/value/color/space/rec2020.dart @@ -11,12 +11,6 @@ import '../conversions.dart'; import '../space.dart'; import 'utils.dart'; -/// A constant used in the rec2020 gamma encoding/decoding functions. -const _alpha = 1.09929682680944; - -/// A constant used in the rec2020 gamma encoding/decoding functions. -const _beta = 0.018053968510807; - /// The rec2020 color space. /// /// https://www.w3.org/TR/css-color-4/#predefined-rec2020 @@ -29,22 +23,14 @@ final class Rec2020ColorSpace extends ColorSpace { const Rec2020ColorSpace() : super('rec2020', rgbChannels); @protected - double toLinear(double channel) { - // Algorithm from https://www.w3.org/TR/css-color-4/#color-conversion-code - var abs = channel.abs(); - return abs < _beta * 4.5 - ? channel / 4.5 - : channel.sign * (math.pow((abs + _alpha - 1) / _alpha, 1 / 0.45)); - } + double toLinear(double channel) => + // Algorithm from https://drafts.csswg.org/css-color-4/#color-conversion-code + channel.sign * math.pow(channel.abs(), 2.4); @protected - double fromLinear(double channel) { - // Algorithm from https://www.w3.org/TR/css-color-4/#color-conversion-code - var abs = channel.abs(); - return abs > _beta - ? channel.sign * (_alpha * math.pow(abs, 0.45) - (_alpha - 1)) - : 4.5 * channel; - } + double fromLinear(double channel) => + // Algorithm from https://drafts.csswg.org/css-color-4/#color-conversion-code + channel.sign * math.pow(channel.abs(), 1 / 2.4); @protected Float64List transformationMatrix(ColorSpace dest) => switch (dest) { diff --git a/pkg/sass-parser/CHANGELOG.md b/pkg/sass-parser/CHANGELOG.md index 3bf14ce68..9970a8dfb 100644 --- a/pkg/sass-parser/CHANGELOG.md +++ b/pkg/sass-parser/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.43 + +* No user-visible changes. + ## 0.4.42 * No user-visible changes. diff --git a/pkg/sass-parser/package.json b/pkg/sass-parser/package.json index c0ad58177..c5c4822c3 100644 --- a/pkg/sass-parser/package.json +++ b/pkg/sass-parser/package.json @@ -1,6 +1,6 @@ { "name": "sass-parser", - "version": "0.4.42", + "version": "0.4.43", "description": "A PostCSS-compatible wrapper of the official Sass parser", "repository": "sass/dart-sass", "author": "Google Inc.", diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index 14d75f720..e163f3261 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/pkg/sass_api/CHANGELOG.md @@ -1,3 +1,7 @@ +## 17.4.0 + +* No user-visible changes. + ## 17.3.3 * No user-visible changes. diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index 8f558a5be..5e8357d46 100644 --- a/pkg/sass_api/pubspec.yaml +++ b/pkg/sass_api/pubspec.yaml @@ -2,7 +2,7 @@ name: sass_api # Note: Every time we add a new Sass AST node, we need to bump the *major* # version because it's a breaking change for anyone who's implementing the # visitor interface(s). -version: 17.3.3 +version: 17.4.0 description: Additional APIs for Dart Sass. homepage: https://github.com/sass/dart-sass @@ -10,7 +10,7 @@ environment: sdk: ">=3.6.0 <4.0.0" dependencies: - sass: 1.97.3 + sass: 1.98.0 dev_dependencies: dartdoc: ">=8.0.14 <10.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 4f48c5e23..54feaa3c9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.97.3 +version: 1.98.0 description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass