Rhinoscript HSL to RGB (BUG?)

Hi,

I wanted to know why is there a division by /240 in rhinoscript

in Rhinocommon the values go from 0 to 1. I dont understand where is the 240 coming from.

Am I missing something?

http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Display_ColorHSL__ctor.htm

Does this help?

– Dale

That is the first place I went to to check. I still dont understand why in the rhinoscript library the values are divided by 240.

@stevebaer do you have any idea?

I’m betting it’s doing this based on a Windows API function. Windows, AFAIK, is the only system to use 240 for HSL. Look at colors in MSPaint. I came across the history behind it a while ago, but now I can’t find it. It had something to do with the data type size and conversion algorithm, or something like that, and is essentially an early part of Windows that we continue to live with…

This was written quite a while ago and I can’t remember the details without doing some significant digging around. Is this causing problems?

not causing an issue as I now know that it is getting divided by 240. I had a quick check and it seems @Tom_Copple is correct. Just that the Rhino conversion is using values from 0-1.

Something similar to the following link.

Hi Miguel,

The ColorHSL function requires HSL components in their normalized form - ranging from 0.0 to 1.0. Dividing each component by the max HSL value, 240, accomplishes this.

– Dale