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.
# Public Properties
Property | Description |
---|---|
b | integer |
blue | integer |
g | integer |
green | integer |
hex | string |
luma | float |
r | integer |
red | integer |
rgb | string |
# b
- Type
- integer
- Default value
null
- Access
- Read-only
# blue
- Type
- integer
- Default value
null
- Access
- Read-only
# g
- Type
- integer
- Default value
null
- Access
- Read-only
# green
- Type
- integer
- Default value
null
- Access
- Read-only
# hex
- Type
- string
- Default value
null
- Access
- Read-only
# luma
- Type
- float
- Default value
null
- Access
- Read-only
# r
- Type
- integer
- Default value
null
- Access
- Read-only
# red
- Type
- integer
- Default value
null
- Access
- Read-only
# rgb
- Type
- string
- Default value
null
- Access
- Read-only
# 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.
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()
Returns
# getB()
Returns
# getBlue()
Returns
# getG()
Returns
# getGreen()
Returns
# getHex()
Returns the color as a hex.
Returns
# 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
Returns
# getR()
Returns
# getRed()
Returns
# getRgb()
Returns the color in rgb()
syntax.
Returns
# serialize()
Returns the object’s serialized value.
Returns
mixed
– The serialized value