Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Color 4] Various fixes #3858

Merged
merged 8 commits into from
May 9, 2024
Merged

[Color 4] Various fixes #3858

merged 8 commits into from
May 9, 2024

Conversation

nex3
Copy link
Contributor

@nex3 nex3 commented May 2, 2024

  • Zero missing channels before conversion in color.same()

    Otherwise, you get weird behavior when conversion to the XYZ space preserves missing channels, which can cause colors to be considered same() even when they're visually distinct.

  • Treat missing channels as distinct from 0 for ==

    Now that color.same() explicitly treats missing channels as 0, it makes more sense for == to fill the stricter role and treat them as different. This is especially true because it already requires (non-legacy) colors to be in the same space, so missing channels are much more consistently meaningful than they would be in cross-space comparisons.

  • Improve specifications for missing alpha values

@nex3 nex3 requested review from Goodwine and mirisuzanne May 2, 2024 22:27
Otherwise, you get weird behavior when conversion to the XYZ space
preserves missing channels, which can cause colors to be considered
`same()` even when they're visually distinct.
@nex3 nex3 force-pushed the same-zero-before-conversion branch from 88995ea to 2cde27c Compare May 2, 2024 22:29
@nex3 nex3 changed the title [Color 4] Zero missing channels before conversion in color.same() [Color 4] Further improvements to color equality May 2, 2024
@nex3 nex3 force-pushed the same-zero-before-conversion branch from 745f59f to 0026eae Compare May 2, 2024 22:41
Now that `color.same()` explicitly treats missing channels as 0, it
makes more sense for `==` to fill the stricter role and treat them as
different. This is especially true because it already
requires (non-legacy) colors to be in the same space, so missing
channels are much more consistently meaningful than they would be in
cross-space comparisons.
@nex3 nex3 force-pushed the same-zero-before-conversion branch from 0026eae to ca967a4 Compare May 2, 2024 22:59
nex3 added a commit to sass/dart-sass that referenced this pull request May 3, 2024
@nex3 nex3 changed the title [Color 4] Further improvements to color equality [Color 4] Various fixes May 3, 2024
@nex3 nex3 requested a review from Goodwine May 3, 2024 22:20
@nex3 nex3 force-pushed the same-zero-before-conversion branch from c939218 to 97d6902 Compare May 3, 2024 22:25
@nex3 nex3 force-pushed the same-zero-before-conversion branch from 97d6902 to c8fe2ed Compare May 3, 2024 23:28
@nex3 nex3 requested a review from Goodwine May 9, 2024 00:28
@@ -2300,7 +2306,8 @@ ie-hex-str($color)

* If `$color` is not a color, throw an error.

* Let `rgb` be the result of [converting] and [gamut mapping] `$color` to `rgb`.
* Let `rgb` be the result of [converting] and [gamut mapping] `$color` to `rgb`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it feels a little odd that rgb here stands for a variable and for a channel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's pretty common here to use the name of a color space to represent "the current color in that space". It is a bit odd but I think not so much that a reader can't get used to it, and it's substantially terser than using something like rgbColor everywhere.

@nex3 nex3 merged commit 31eefa5 into feature.color-4 May 9, 2024
9 checks passed
@nex3 nex3 deleted the same-zero-before-conversion branch May 9, 2024 20:17
nex3 added a commit to sass/dart-sass that referenced this pull request May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants