-
Notifications
You must be signed in to change notification settings - Fork 0
01 Creating measure object
First you should define an object corresponding to the values you want to use. All the available objects fall under the tei187\ColorTools\ColorModels
namespace. Further on we may refer to it these objects as color models, samples or measures.
use tei187\ColorTools\ColorModels\xyY;
use tei187\ColorTools\ColorModels\XYZ;
use tei187\ColorTools\ColorModels\LCh;
use tei187\ColorTools\ColorModels\LCh_uv;
use tei187\ColorTools\ColorModels\Luv;
use tei187\ColorTools\ColorModels\Lab;
use tei187\ColorTools\ColorModels\RGB;
use tei187\ColorTools\ColorModels\HSL;
use tei187\ColorTools\ColorModels\HSV;
$xyY = new xyY(); // xyY
$XYZ = new XYZ(); // XYZ
$LCh = new LCh(); // LCh(ab)
$LCH_uv = new LCh_uv(); // LCh(uv)
$Luv = new Luv(); // Luv
$Lab = new Lab(); // Lab
$RGB = new RGB(); // RGB
$HSL = new HSL(); // HSL
$HSV = new HSV(); // HSV
For the sake of conversion algorithms, all available models are divided into two groups: device dependent and independent models. Device independent models include xyY, XYZ, Lab, Luv, LCh(ab), LCh(uv). Device dependent models include RGB, HSL*, HSV*. In constructors for classes of both types, the first argument is always the appropriate values to the model, while the second argument will be the illuminant (by default D65) for device independent models and RGB primaries (by default sRGB) for device dependent models. Device independent models also use the third argument, being standard observer angle (by default 2 degrees).
* technically, HSL & HSV can be both kinds, however due to easier abstraction and conversion through RGB, in this package they are assumed to be device dependent.
use tei187\ColorTools\ColorModels\Lab;
# Creating Lab object with:
# - values L:63.12, a:-3.12, b:3.31
# - D50 illuminant
# - 10 degree standard observer
$Lab = new Lab([ 63.12, -3.12, 3.31 ], 'D50', 10);
use tei187\ColorTools\ColorModels\RGB;
# Creating RGB object with:
# - values: #c7fe00
# - primaries: Adobe RGB 1998
$RGB = new RGB("#c7fe00", 'AdobeRGB1998');