Skip to content

Commit fac2dbe

Browse files
authored
Specify XyzD50 and XyzD65 WHITE_COMPONENTS exactly (#129)
This fixes two 1-ULP rounding issues (first component in `XyzD50` and last component in `XyzD65`).
1 parent 7e966a1 commit fac2dbe

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ This release has an [MSRV][] of 1.82.
1919

2020
* Support for the ACES2065-1 color space. ([#124][] by [@tomcur][])
2121

22+
### Fixed
23+
24+
* Specify some `ColorSpace::WHITE_COMPONENTS` to higher precision. ([#128][], [#129][] by [@tomcur][])
25+
2226
## [0.2.2][] (2025-01-03)
2327

2428
This release has an [MSRV][] of 1.82.
@@ -111,6 +115,8 @@ This is the initial release.
111115
[#118]: https://github.com/linebender/color/pull/118
112116
[#119]: https://github.com/linebender/color/pull/119
113117
[#124]: https://github.com/linebender/color/pull/124
118+
[#128]: https://github.com/linebender/color/pull/128
119+
[#129]: https://github.com/linebender/color/pull/129
114120

115121
[Unreleased]: https://github.com/linebender/color/compare/v0.2.2...HEAD
116122
[0.2.2]: https://github.com/linebender/color/releases/tag/v0.2.2

color/src/colorspace.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ impl ColorSpace for XyzD50 {
679679

680680
const TAG: Option<ColorSpaceTag> = Some(ColorSpaceTag::XyzD50);
681681

682-
const WHITE_COMPONENTS: [f32; 3] = [0.9642956, 1., 0.8251046];
682+
const WHITE_COMPONENTS: [f32; 3] = [3457. / 3585., 1., 986. / 1195.];
683683

684684
fn to_linear_srgb(src: [f32; 3]) -> [f32; 3] {
685685
// XYZ_to_lin_sRGB * D50_to_D65
@@ -764,7 +764,7 @@ impl ColorSpace for XyzD65 {
764764

765765
const TAG: Option<ColorSpaceTag> = Some(ColorSpaceTag::XyzD65);
766766

767-
const WHITE_COMPONENTS: [f32; 3] = [0.9504559, 1., 1.0890577];
767+
const WHITE_COMPONENTS: [f32; 3] = [3127. / 3290., 1., 3583. / 3290.];
768768

769769
fn to_linear_srgb(src: [f32; 3]) -> [f32; 3] {
770770
const XYZ_TO_LINEAR_SRGB: [[f32; 3]; 3] = [

0 commit comments

Comments
 (0)