Message Boards Message Boards

[✓] Get Hue[0.5, 1., 1.1] ?

GROUPS:

Why values for saturation and brightness are not clipped to 1 if values >1 are given to function Hue? On my system (Windows 10, Mathematica 11.1.1) the function remains un-evaluated for such values, contrary to what the documentation to Hue says.

POSTED BY: Ulrich Mutze
Answer
13 days ago

I am not having a problem with this working as expected. For example:

Graphics3D[{Hue[1/3, 3, 5, .5], Sphere[]}]

which has saturation and brightness of 3 and 5, shows the exact image as on the Documentation Page.

Do you have an example that is not working correctly?

POSTED BY: A J Hardesty
Answer
12 days ago

Hue[h,s,b] does not evaluate. It simply formats (i.e. displays) in a certain way. It is only this formatting that fails with out-of-range value, but Hue still works as a graphics directive as A J Hardesty showed.

Try Hue[.1, .2, .3] // FullForm to see that no evaluation took place.

POSTED BY: Szabolcs Horvát
Answer
12 days ago

Many thanks, Sirs, for your helpful and prompt answers. They helped me to focus on the meaning of graphical directives. I hope that you will find your insight properly represented in the appended file. Thank you, again.

Attachments:
POSTED BY: Ulrich Mutze
Answer
12 days ago

Perhaps this hack will work for bringing colour directives into a canonical form:

In[66]:= canon[col_?ColorQ] := ColorConvert[col, Head[col]]

In[67]:= canon[Hue[1/3, 3, 5, .5]]
Out[67]= Hue[0.3333333333333333, 1., 1., 0.5]

My opinion is that clipping of out-of-range values should be implemented in a way that it extends to the entire behavior, in particular to the way an expression displays on screen in isolation.

Agreed. And because I would expect different functions to have different implementations for colour handling (though I may be wrong...), I would be very careful with such out-of-range values. Just because they work in one context, they may not work in a different one (and that different one may directly concern functionality rather than harmless formatting).

But then taking this thought one step further:

One might say that the lack of formatting is a good thing. It serves as a warning that the values are out of range. Actually, I think I prefer it this way (for this single reason).

POSTED BY: Szabolcs Horvát
Answer
12 days ago

Your 'hack' works fine as you can see from the appended file. Thanks!

Attachments:
POSTED BY: Ulrich Mutze
Answer
12 days ago

Group Abstract Group Abstract