Brian Dunning's FileMaker Custom Functions

RGBtoHSL ( redPercentage ; greenPercentage ; bluePercentage )

Converts color from RGB percentages to HSL values.

  Average rating: 4.4 (24 votes) Log in to vote

Joe Rovang   Joe Rovang

Share on Facebook Share on Twitter

  Sample input:
RGBtoHSL ( 1; 0; 0 ) // red
  Sample output:


.5

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This function converts the specified color RGB percentages to hue, saturation, and lightness (HSL) values. (Note that HSL is not the same as HSB/HSV!)

All values except hue are in decimals between 0 and 1, inclusively. RGB values on the 0-255 scale must be divided by 255 before using them in this function.

 

Comments

Alexander Zueiv   Alexander Zueiv, Tashkent
Oct 20, 2012
The example RGBtoHSL ( 1; 0; 0 ) returns "0¶?¶1".

The mistake is probably in the line 14:

sumC = maxC + maxC;

It should probably be:

sumC = maxC + minC;

Is that correct?
 
Joe Rovang   Joe Rovang
Oct 20, 2012
Yes, thanks, careless translation from Java. Edited.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.