Message Boards Message Boards

0
|
3595 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

Why Hue[0] == Hue[1] does not evaluate to True or anything?

Posted 5 years ago

I am curious to understand why Hue[0] == Hue[1] does not evaluate to either True or False or at least some other Explanation message. Instead I get the initial expression with Color object substitution. Then using === I get False but we know that Hue[0] and Hue[1] are identical so at least one of == or === should have provided me with a True. See code below:

In[83]:= Hue[0] === Hue[1]
Out[83]= False

In[89]:= Hue[0] == Hue[1]
Out[89]= Hue[0] == Hue[1]

In[85]:= ColorConvert[Hue[0], "RGB"] // InputForm
Out[85]//InputForm= RGBColor[1., 0., 0.]

In[86]:= ColorConvert[Hue[1], "RGB"] // InputForm
Out[86]//InputForm= RGBColor[1., 0., 0.]
POSTED BY: LV VS

Hue[a] (with some number a) does not evaluate internally to an RGB color. (i.e. it stays as Hue[a] in the memory).

Equal will return True/False by checking if the LHS and RHS are equal. In this case they are not; it just looks at this expression structurally if you willÂ… Equal does not compare colors!

If you want to compare colors, you could check the ColorDistance between the two, and check if it is 0. This will compare colors.

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract