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

Multi-select option field data class.

View source

Public Properties

$b

Type
integer
Access
Read-only

View source

Signature

public integer getB ( )

$blue

Type
integer
Access
Read-only

View source

Signature

public integer getBlue ( )

$g

Type
integer
Access
Read-only

View source

Signature

public integer getG ( )

$green

Type
integer
Access
Read-only

View source

Signature

public integer getGreen ( )

$hex

Type
string
Access
Read-only

View source

Signature

public string getHex ( )

$luma

Type
float
Access
Read-only

View source

Signature

public float getLuma ( )

$r

Type
integer
Access
Read-only

View source

Signature

public integer getR ( )

$red

Type
integer
Access
Read-only

View source

Signature

public integer getRed ( )

$rgb

Type
string
Access
Read-only

View source

Signature

public string getRgb ( )

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()
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

Signature

public void __construct ( \craft\fields\data\string $hex, array $config = [] )

__toString()

Signature

public string __toString ( )

getB()

Signature

public integer getB ( )

getBlue()

Signature

public integer getBlue ( )

getG()

Signature

public integer getG ( )

getGreen()

Signature

public integer getGreen ( )

getHex()

Returns the color as a hex.

View source

Returns

string

Signature

public string getHex ( )

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

Signature

public float getLuma ( )

getR()

Signature

public integer getR ( )

getRed()

Signature

public integer getRed ( )

getRgb()

Returns the color in rgb() syntax.

View source

Returns

string

Signature

public string getRgb ( )

serialize()

Returns the object’s serialized value.

View source

Returns

mixed – The serialized value

Signature

public mixed serialize ( )