Skip to content

Fix Hue might get negative#111

Merged
batzen merged 2 commits intoControlzEx:developfrom
timunie:HSL_Fix
Aug 4, 2020
Merged

Fix Hue might get negative#111
batzen merged 2 commits intoControlzEx:developfrom
timunie:HSL_Fix

Conversation

@timunie
Copy link
Copy Markdown
Contributor

@timunie timunie commented May 2, 2020

In some rare cases Hue might get negative. The resulting Color is still correct, but we should nevertheless avoid this due to the defined Range from 0 to 360.

Sorry that I missed this.

In some rare cases Hue might get negative. The resulting Color is still correct, but we should nevertheless avoid this due to the defined Range from 0 to 360
{
this.H += 360;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to just set it to 0 in this case?
I am no color expert, but i wouldn't expect it to just add 360.
In which cases can it even go below 0?
To be honest i just copied the code without understanding much about HSL.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @batzen consider the Hue range to be a circle. If you have negative hue due to the formulas are not using absolute values, you may get negative Hue. In this case you would just go in the opposite direction on the color wheel. Adding 360° will not change the Hue but makr it positve.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @batzen ,
I modified my ColorPicker example where I use HSV-Color. The Hue is calculated the same way as in the HSL struckt.

Without adding +360°:
ColorPicker_01

With adding +360°:*
ColorPicker_02

Hue wheel:
image

I hope this helps for better understanding.

Have a nice Sunday
Tim

@batzen
Copy link
Copy Markdown
Member

batzen commented Jun 13, 2020

Sorry for responding so late. I added my comment a few weeks ago but forgot to submit it...

@batzen batzen merged commit 0eacf87 into ControlzEx:develop Aug 4, 2020
@punker76 punker76 added this to the 4.4.0 milestone Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants