Notifications
Clear all

[Closed] Comparing color values

I’m very confused as to why this will work…


s=sphere()
   s.wirecolor = (color 0 0 124)
   s.wirecolor == (color 0 0 124)

…but then this won’t…


meditMaterials[1].diffuseColor = (color 0 0 124)
  meditMaterials[1].diffuseColor == (color 0 0 124)

Can anybody explain what the difference is here?

4 Replies

Remember that a double equal sign is a comparison and a single one is an assignment. I’m sure you probably already know this.

This works for me (with a standard material in the first slow)


meditmaterials[1].diffuseColor = (color 0 0 124)

-Colin

Hi Colin,

Thanks for your reply. I was actually wondering why, in both situations, immediately after assigning the color value the wirecolor says they are equal and the diffuse color would say they are not equal.

Here it is again, but storing the color values in a variable first to make absolutely sure they should be equal.


  s=sphere()
  c = (color 0 0 124)
  s.wirecolor = c
  s.wirecolor == c
  

  c = (color 0 0 124)
  meditMaterials[1].diffuseColor = c
  meditMaterials[1].diffuseColor == c
  

I should have been more specific before, sorry about that.

It’s because it’s not actually 124… neither are, but at least one of the two matches regardless


formattedPrint c
"(color 0 0 124.00001)"
formattedPrint $.wireColor
"(color 0 0 124.00001)"
formattedPrint meditMaterials[1].diffuseColor
"(color 0 0 124.00002)"

Those sneaky decimals!

I thought that might have been it, but I was testing by just calling on the blue channel and not using formattedPrint. I thought it was odd that it was returning a float value, but it was always just showing as .0 in the listener, so I dismissed it.

Thanks Richard, appreciate it!