Grasshopper

algorithmic modeling for Rhino

So I am just playing around with the gradient node and noticed something strange.

If I double click one of the control points in the gradient you can set the ColorLeft and ColorRight.

If I do that and pick for example white for ColorLeft and black for ColorRight, then the output is not RGB values anymore for pure white, but the string "white", thus making any calculations using the values impossible.

Is there a way to:

a) have the gradient always output numerical values

or

b) convert rbg values mixed with strings of pure colors (white, black, etc.) to only numerical values

Thanks, Armin.

Views: 2712

Replies to This Discussion

Ok, so I just noticed if I enter 255,255,255 it uses the numerical values in the output. Strangely if you enter something invalid, for example just accidentally put "255.255.255" it says "255.255.255 is not a valid value for Int32". But how can a string be a valid Int32? 

This must be some sort of system thingy. Very strange indeed.

PS: I should mention that the reason I need numerical values is that I just need the Lightness value of the color. To be able to convert RGB to HSL I need proper values though.

What you are seeing is the Panel being clever and interpreting the value as White. If you plugged it into a Colour Param on any component that requires it it will be the correct RGB value.

Ah ok there is a color split node. Doh!

It converts it to numbers. Ok, so now its easy to convert to HSL using 3 inputs instead of 1.

Thanks!

ps: for future reference if someone comes across this, the code inside the C# node is:

System.Drawing.Color color = Color.FromArgb(R, G, B);

H = color.GetHue();
S = color.GetSaturation();
L = color.GetBrightness();

there is a component for this but V is used as the Output for L

Ok, thats true. But HSV is not the same as HSL ;)

Actually it seems that the HSV component is actually outputting HSL and not HSV.

http://en.wikipedia.org/wiki/HSL_and_HSV

I think this is why there is a "split AHSV" and a "color AHSL" node. Why not have a split and join for both, but a split for one and a join for the other!?

Is V not the value for Brightness? your code is color.GetBrightness()

That is true. But the V is not the same as L. So you're right, that I can use the HSV component in this case. But it means that the HSV component should be called HSL (see below).

Ok, I knew it. The HSV component should be named HSL!

As you can see the V value for the red color is 100, but the V value that HSV outputs is actually the L value of 0.5.

Wow, nobody noticed this before?

Report it as a bug

It would seem Daniel noticed this last week, but you would need to translate the post to see that: http://www.grasshopper3d.com/forum/topics/assign-a-number-to-a-colo...

Ah, but its still strange that it is only "clever" for the first color and not the ones after that. Note that it says "black" in the first 2 lines, but then "255,255,255" in the lines after that.

So its fair to say in this case its only clever for a while :) ADHD, I guess :D

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service