PHP Class Jyxo\Color

Author: Roman Řáha
Datei anzeigen Open project: jyxo/php

Public Methods

Method Description
__construct ( mixed $color = null ) Constructor.
__toString ( ) : string Returns textual (#RRGGBB) representation of the current color.
getBinary ( ) : integer Returns the current color in binary form 0 - black, 1 - white).
getBlue ( ) : integer Returns the blue component luminance.
getGreen ( ) : integer Returns the green component luminance.
getHex ( ) : string Returns the current color as a six-digit hexadecimal number.
getLuminance ( ) : integer Returns the color luminance according to the human perception.
getRed ( ) : integer Returns the red component luminance.
getRgb ( ) : array Returns the current color as an array of the red, green and blue components.
setBlue ( integer | string $blue ) : self Sets the blue component luminance.
setGreen ( integer | string $green ) : self Sets the green component luminance.
setLuminance ( integer | string $luminance ) : self Sets the color in grayscale according to the luminance value.
setRed ( integer | string $red ) : self Sets the red component luminance.
toGrayScale ( ) : self Returns the currect color converted to grayscale.
toInverse ( ) : self Returns an inverse color.

Private Methods

Method Description
initFromHex ( string $hex ) : self Sets color components using a hexadecimal RRGGBB string.
initFromInt ( integer $int ) : self Sets color components from an integer.
initFromRgb ( array $rgb ) : self Sets color components from an array.
toInt ( integer | string $value ) : integer Returns the color luminance as a decimal integer.

Method Details

__construct() public method

Accepts the following definition formats: * Hexadecimal string (with or without the hashmark at the beginning) * Array with red, green and blue component luminance values (in this order) * Number, * {@link \Jyxo\Color}, * null
public __construct ( mixed $color = null )
$color mixed Color definition

__toString() public method

Returns textual (#RRGGBB) representation of the current color.
public __toString ( ) : string
return string

getBinary() public method

Returns the current color in binary form 0 - black, 1 - white).
public getBinary ( ) : integer
return integer

getBlue() public method

Returns the blue component luminance.
public getBlue ( ) : integer
return integer

getGreen() public method

Returns the green component luminance.
public getGreen ( ) : integer
return integer

getHex() public method

Returns the current color as a six-digit hexadecimal number.
public getHex ( ) : string
return string

getLuminance() public method

Returns the color luminance according to the human perception.
public getLuminance ( ) : integer
return integer

getRed() public method

Returns the red component luminance.
public getRed ( ) : integer
return integer

getRgb() public method

Returns the current color as an array of the red, green and blue components.
public getRgb ( ) : array
return array

setBlue() public method

Sets the blue component luminance.
public setBlue ( integer | string $blue ) : self
$blue integer | string Component luminance
return self

setGreen() public method

Sets the green component luminance.
public setGreen ( integer | string $green ) : self
$green integer | string Component luminance
return self

setLuminance() public method

Sets the color in grayscale according to the luminance value.
public setLuminance ( integer | string $luminance ) : self
$luminance integer | string Luminance
return self

setRed() public method

Sets the red component luminance.
public setRed ( integer | string $red ) : self
$red integer | string Component luminance
return self

toGrayScale() public method

Returns the currect color converted to grayscale.
public toGrayScale ( ) : self
return self

toInverse() public method

Returns an inverse color.
public toInverse ( ) : self
return self