ph_huergbtoxy PowerHome formula function
Description
Converts an RGB color value into Philips Hue XY values 
Syntax
ph_huergbtoxy ( al_rgb, as_xy, as_gamut, ad_rx, ad_ry, ad_gx, ad_gy, ad_bx, ad_by )
Argument Description
al_rgb Long. The RGB color value you wish to convert. Ex: rgb(255,120,170)
as_xy String. Specifies whether to return the X or the Y value. Valid values are "X" or "Y"
as_gamut String. Specifies the gamut to be used for the conversion. See Usage below
ad_rx Double. The gamut X value to use for Red
ad_ry Double. The gamut Y value to use for Red
ad_gx Double. The gamut X value to use for Green
ad_gy Double. The gamut Y value to use for Green
ad_bx Double. The gamut X value to use for Blue
ad_by Double. The gamut Y value to use for Blue
Return value
Double. Returns either the X or Y value for the specified RGB color in al_rgb 
Usage
Use this function calculate Philips Hue X and Y color values from a standard RGB color value. 

Valid values for as_gamut are:

  • "a" - Use the Philips Hue A gamut values
  • "b" - Use the Philips Hue B gamut values
  • "c" - Use the Philips Hue C gamut values
  • "full" - Use full range gamut values

    If you specify one of the gamut values above (a, b, c, or full), you do NOT need to specify ANY of the ad_rx, ad_ry, ad_gx, ad_gy, ad_bx, or ad_by values (set all of these values to 0). If you wish to specify your own gamut ranges, set the as_gamut parameter to blank ("") and then specify the six gamut values in ad_rx thru ad_by. Gamut values should be a positive number between 0 and 1 inclusive.

    See the Philips Hue API for more details on color conversions and the actual gamut values that are used

  • Examples
    The following examples demonstrate typical syntax/usage for this function.
    • ph_huergbtoxy(rgb(255,120,170),"x","a",0,0,0,0,0,0) - Returns 0.474956426332266 which is the X value using gamut A 
    • ph_huergbtoxy(rgb(255,120,170),"y","",0.704,0.296,0.2151,0.7106,0.138,0.08) - Returns 0.26833168907959 which is the Y value using the manually specified gamut values (which in this example are the same values as the Philips Hue gamut A)