-
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.
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 (technically, HSL & HSV can be both kinds, however due to easier abstraction in this package they are assumed to be device dependent). 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 D50) for device independent models and RGB primaries (by default sRGB) for device dependent models.
Let's say that you have L*a*b values like [ L: 63.12, a: -3.12, b: 3.31 ], measured under D65 illuminant. In order to create a valid object, you need to:
use tei187\ColorTools\Measures\Lab;
$obj = new Lab([ 63.12, -3.12, 3.31 ], 'D65');
or
use tei187\ColorTools\Measures\Lab;
$obj = new Lab();
$obj->setValues([ 63.12, -3.12, 3.31 ])
->setIlluminant('D65');
First lets create a new blank instance, we are going to assign the values later on:
use tei187\ColorTools\Measures\RGB;
$rgb = new RGB();
RGB-based models can assign values in three different methods, using
- 0 to 1 floats,
- 0 to 255 floats
- 00 to ff hex strings.
$float_0_1 = $rgb->setValues([ .31, .54, .25 ])->getValues();
/*
array(3) {
["R"]=> float(0.31)
["G"]=> float(0.54)
["B"]=> float(0.25)
}
*/
$float_0_255 = $rgb->setValues([ 67, 123, 201 ])->getValues();
/*
array(3) {
["R"]=> float(0.26274509803922)
["G"]=> float(0.48235294117647)
["B"]=> float(0.78823529411765)
}
*/
$hex_00_ff = $rgb->setValues("#c5834f")->getValues();
/*
array(3) {
["R"]=> float(0.77254901960784)
["G"]=> float(0.51372549019608)
["B"]=> float(0.30980392156863)
}
*/