Recommend this page to a friend! |
Classes of Christian Vigh | Color Tools | README.md | Download |
|
DownloadINTRODUCTIONThe Color class allows for conversion between different colorimetric models, namely :
EXAMPLEInstantianting a Color object will automatically convert the color you supplied to all the other colorimetric schemes :
The above example found the color you specified in the ColorNames.txt file, and converted this color name to all other colorimetric models currently support, which are accessible as properties ; for example :
is an array of three elements, containing the Red, Green and Blue parts of the color you supplied to the constructor (White), so it will contain the values 0xFF, 0xFF and 0xFF. You can reuse an existing Color object to specify another color, using the SetColor() method :
The class will recognize the specified value to be "Blue", a value which will be accessible through the $ColorName property. See the Reference section for more information about methods, properties and constants available for this class. REFERENCEMethodsConstructor
Creates a Color object using the specified color value, which can have one of the following forms :
Color names are not case-sensitive, as well as keywords such as RGB, GRAYSCALE, etc. If a single integer or an array of bytes is specified, the caller must specify a constant of type COLOR\_SCHEME\_\* to indicate which colorimetric model is to be used for interpreting the value. NormalizedRGBValue
Normalizes an RGB value by applying the following process :
The function returns the normalized RGB value as a string, or false if an error occurred. SetColor
Assigns a new color to the specified object. All the colorimetric properties are recomputed after that. ToArray
Returns an associative array having the following entries :
PropertiesAll the properties listed in the following section should be considered as read-only. RGBStringThe normalized RGB color, that can be used as is for any css or HTML color attribute. ColorNameHuman-readable color name. This value will be an empty string if the color has no correspondance in the file ColorNames.txt. RGBA set of 3 byte values for the RGB colorimetric model. HSLA set of 3 byte values for the HSL colorimetric model. HSBA set of 3 byte values for the HSB colorimetric model. CMYA set of 3 byte values for the CMY colorimetric model. CMYKA set of 4 byte values for the CMYK colorimetric model. WebSafeA set of 3 byte values for the Websafe RGB colorimetric model. GrayScaleA set of 3 byte values corresponding to the grayscale version of the underlying color. ConstantsThe Color class defines the following constants, which indicate the colorimetric model associated to a string ; such a constant must be specified to either the class constructor or the SetValue() method, when the specified value does not allow to determine which colorimetric model is to be used :
|