Skip to content

ColorData ​

Type
Class
Namespace
craft\fields\data
Inherits
craft\fields\data\ColorData » yii\base\BaseObject
Implements
craft\base\Serializable, yii\base\Configurable
Since
3.0.0

Multi-select option field data class.

View source

Public Properties ​

PropertyDescription
binteger
blueinteger
ginteger
greeninteger
hinteger
hexstring
hslstring
hueinteger
linteger
lightnessinteger
lumafloat
rinteger
redinteger
rgbstring
sinteger
saturationinteger

b ​

Type
integer
Default value
null

View source

blue ​

Type
integer
Default value
null

View source

g ​

Type
integer
Default value
null

View source

green ​

Type
integer
Default value
null

View source

h ​

Type
integer
Default value
null
Access
Read-only
Since
3.7.26

View source

hex ​

Type
string
Default value
null

View source

hsl ​

Type
string
Default value
null
Access
Read-only
Since
3.7.26

View source

hue ​

Type
integer
Default value
null
Access
Read-only
Since
3.7.26

View source

l ​

Type
integer
Default value
null
Access
Read-only
Since
3.7.26

View source

lightness ​

Type
integer
Default value
null
Access
Read-only
Since
3.7.26

View source

luma ​

Type
float
Default value
null

View source

r ​

Type
integer
Default value
null

View source

red ​

Type
integer
Default value
null

View source

rgb ​

Type
string
Default value
null

View source

s ​

Type
integer
Default value
null
Access
Read-only
Since
3.7.26

View source

saturation ​

Type
integer
Default value
null
Access
Read-only
Since
3.7.26

View source

Public Methods ​

MethodDescription
__call()Calls the named method which is not a class method.
__construct()Constructor.
__get()Returns the value of an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__toString()
__unset()Sets an object property to null.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
getB()
getBlue()
getG()
getGreen()
getH()
getHex()Returns the color as a hex.
getHsl()Returns the color in hsl() syntax.
getHue()
getL()
getLightness()
getLuma()Get brightness of an image. Values closer to 0 are darker, closer to 1 are lighter.
getR()
getRed()
getRgb()Returns the color in rgb() syntax.
getS()
getSaturation()
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined.
init()Initializes the object.
serialize()Returns the object’s serialized value.

__construct() ​

Constructor.

View source

Arguments ​

  • $hex (string) – Hex color value, beginning with #. (Shorthand is not supported, e.g. #f00.)
  • $config (array) – Name-value pairs that will be used to initialize the object properties

__toString() ​

View source

Returns ​

string

getB() ​

View source

Returns ​

integer

getBlue() ​

View source

Returns ​

integer

getG() ​

View source

Returns ​

integer

getGreen() ​

View source

Returns ​

integer

getH() ​

Since
3.7.26

View source

Returns ​

integer

getHex() ​

Returns the color as a hex.

View source

Returns ​

string

getHsl() ​

Since
3.7.26

Returns the color in hsl() syntax.

View source

Returns ​

string

getHue() ​

Since
3.7.26

View source

Returns ​

integer

getL() ​

Since
3.7.26

View source

Returns ​

integer

getLightness() ​

Since
3.7.26

View source

Returns ​

integer

getLuma() ​

Get brightness of an image. Values closer to 0 are darker, closer to 1 are lighter.

See also:

View source

Returns ​

float

getR() ​

View source

Returns ​

integer

getRed() ​

View source

Returns ​

integer

getRgb() ​

Returns the color in rgb() syntax.

View source

Returns ​

string

getS() ​

Since
3.7.26

View source

Returns ​

integer

getSaturation() ​

Since
3.7.26

View source

Returns ​

integer

serialize() ​

Returns the object’s serialized value.

View source

Returns ​

mixed – The serialized value