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

# b

Type
integer
Access
Read-only

View source

# blue

Type
integer
Access
Read-only

View source

# g

Type
integer
Access
Read-only

View source

# green

Type
integer
Access
Read-only

View source

# hex

Type
string
Access
Read-only

View source

# luma

Type
float
Access
Read-only

View source

# r

Type
integer
Access
Read-only

View source

# red

Type
integer
Access
Read-only

View source

# rgb

Type
string
Access
Read-only

View source

# Public Methods

Method Description
__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()
getHex() Returns the color as a hex.
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.
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

# getHex()

Returns the color as a hex.

View source

Returns

string

# getLuma()

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

See also:

  • http://stackoverflow.com/a/12228906/1136822 – Stack Overflow answer
  • https://en.wikipedia.org/wiki/Luma_(video) – Luma

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

# serialize()

Returns the object’s serialized value.

View source

Returns

mixed – The serialized value