ph_colorcalc PowerHome formula function
Description
Calculates an RGB color value for a supplied
value based upon min and max color value ranges and min and max value
ranges for the
supplied value
Syntax
ph_colorcalc ( al_colormin, al_colormax, al_minval, al_maxval, al_value )
Argument | Description |
al_colormin | Long. An RGB color value representing the color
to be used for the supplied al_value = al_minval |
al_colormax | Long. An RGB color value representing the
color to be used for the supplied al_value = al_maxval |
al_minval | Long. The minimum value for the supplied al_value parameter |
al_maxval | Long. The maximum value for the supplied al_value parameter |
al_value | Long. The value upon which the returned
calculated color will be based |
Return value
Long. Returns a calculated RGB
color value. If the al_value parameter is equal to the al_minval parameter then
al_colormin will be returned. If al_value is equal to al_maxval then the
al_colormax value will be returned. Any other al_value in between al_minval
and al_maxval will return a calculated color that lies on the spectrum of colors
in between al_colormin and al_colormax.
Usage
Use this function to dynamically
create RGB color values based upon a supplied value (al_value) within a min/max
range (al_minval and al_maxval). This function is useful to set
the Device Status screen background color for Analog I/O and Zwave
device types. If you use this in the context of a light device that has
a min value of 0 representing "off" and a max value of 100 representing
full "on" and the al_colormin value is dark grey and the al_colormax value is
bright yellow, al_value values between 0 and 100 will range between dark grey
and bright yellow with an al_value = 50 being in between the dark grey and
yellow values.
Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_colorcalc(rgb(50,50,50),rgb(255,255,0),0,100,75)
- Returns a value of 838860 which is equivalent to
rgb(204,204,12)