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

[lang] Color -asHSV: Achromatic colors return nan #4369

Merged

Conversation

dyfer
Copy link
Member

@dyfer dyfer commented Mar 28, 2019

Purpose and Motivation

Achromatic colors (black, white, grey) return nan from Color -asHSV method. That makes calculations problematic. Correct me if I'm wrong, but I believe that 0 is an appropriate value for hue and saturation in these cases.

//before fix
Color.black.asHSV
// -> [ nan, nan, 0.0, 1.0 ]
Color.white.asHSV
// -> [ nan, 0.0, 1.0, 1.0 ]
Color.grey.asHSV
// -> [ nan, 0.0, 0.5, 1.0 ]

//after fix
Color.black.asHSV
// -> [ 0.0, 0.0, 0.0, 1.0 ]
Color.white.asHSV
// -> [ 0.0, 0.0, 1.0, 1.0 ]
Color.grey.asHSV
// -> [ 0.0, 0.0, 0.5, 1.0 ]

//also:
Color.hsv(*Color.black.asHSV) == Color.black; //false before fix, true after fix

Types of changes

  • Bug fix
  • Breaking change (?)

To-do list

  • Code is tested
  • All tests are passing (does this need tests?)
  • Updated documentation (documentation for this change is not needed)
  • This PR is ready for review

@mossheim
Copy link
Contributor

mossheim commented Jun 2, 2019

Thanks! Please rebase this against 3.10 -- see our contributor's guide for more information.

@nhthn nhthn added the comp: class library SC class library label Jun 2, 2019
@nhthn nhthn added this to the 3.10.3 milestone Jun 2, 2019
@mossheim
Copy link
Contributor

mossheim commented Jun 4, 2019

Actually, let's merge this to develop as it's a breaking change. I think this is the correct fix -- according to our documentation, it should return values in the range [0, 1] -- but it doesn't strictly preserve old behavior.

@patrickdupuis patrickdupuis modified the milestones: 3.10.3, 3.11 Jun 8, 2019
@patrickdupuis patrickdupuis merged commit fa67b74 into supercollider:develop Jun 8, 2019
@dyfer dyfer deleted the topic/color-asHSV-nanFix branch February 4, 2021 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: class library SC class library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants