PHP Class Grafika\Color

Show file Open project: kosinix/grafika Class Usage Examples

Protected Properties

Property Type Description
$alpha Transparency value 0-1
$hexString Hex string: #FFFFFF

Public Methods

Method Description
__construct ( string $hexString = '', float $alpha = 1 ) Color constructor.
getAlpha ( ) : float Alpha value.
getHexString ( ) : string Get hex string.
getRgb ( ) : array Get RGB array
getRgba ( ) : array Get RGBA array
hexToRgb ( string $hex ) : array Convert hex string to RGB
setAlpha ( float $alpha )
setHexString ( string $hexString ) Set hex string.

Method Details

__construct() public method

Color constructor.
public __construct ( string $hexString = '', float $alpha = 1 )
$hexString string Hex string
$alpha float Transparency value 0-1

getAlpha() public method

Alpha value.
public getAlpha ( ) : float
return float

getHexString() public method

Get hex string.
public getHexString ( ) : string
return string

getRgb() public method

Get RGB array
public getRgb ( ) : array
return array Contains array($r, $g, $b)

getRgba() public method

Get RGBA array
public getRgba ( ) : array
return array Contains array($r, $g, $b, $a)

hexToRgb() public method

Convert hex string to RGB
public hexToRgb ( string $hex ) : array
$hex string Hex string. Possible values: #ffffff, #fff, fff
return array Contains (RGB) values red, green and blue

setAlpha() public method

public setAlpha ( float $alpha )
$alpha float

setHexString() public method

Set hex string.
public setHexString ( string $hexString )
$hexString string

Property Details

$alpha protected property

Transparency value 0-1
protected $alpha

$hexString protected property

Hex string: #FFFFFF
protected $hexString