PHP Class ariColor, kirki

Afficher le fichier Open project: aristath/kirki Class Usage Examples

Méthodes publiques

Свойство Type Description
$alpha integer | float
$blue integer | double
$brightness array
$chroma integer | float
$color string | array The color as defined in the input
$green integer | double
$hex string The HEX value of the color.
$hue integer | float
$instances array Each instance is stored as an object in this array. Allows easier access & performance.
$lightness integer | float
$luminance integer | float
$mode string The mode of this color (hex/rgb/rgba etc.).
$red integer | double
$saturation integer | float
$word_colors array Example: white = #ffffff

Méthodes publiques

Méthode Description
getNew ( $property = '', $value = '' ) : ariColor | null Allows us to get a new instance by modifying a property of the existing one.
get_mode ( string $color ) : string | null Figure out what mode we're using.
newColor ( $color, $mode = 'auto' ) : ariColor Gets an instance for this color.
toCSS ( $mode = 'hex' ) : string Returns a CSS-formatted value for colors.

Private Methods

Méthode Description
__construct ( $color = '', $mode = 'auto' ) The class constructor
dexhex_double_digit ( $value ) : string Convert a decimal value to hex and make sure it's 2 characters
from_hex ( ) : void Starts with a HEX color and calculates all other properties.
from_hsl ( ) : void Starts with an HSL color and calculates all other properties.
from_hsl_array ( ) Calculates the red, green, blue values of an HSL color
from_hsla ( ) : void Starts with an HSLA color and calculates all other properties.
from_rgb ( ) : void Starts with an RGB color and calculates all other properties.
from_rgba ( ) : void Starts with an RGBA color and calculates all other properties.
get_word_colors ( ) : array Gets an array of all the wordcolors
rgb_to_hex ( $red, $green, $blue ) : string Generates the HEX value of a color given values for $red, $green, $blue
set_brightness ( ) Sets the brightness of a color based on the values of red, green, blue
set_hsl ( ) Sets the HSL values of a color based on the values of red, green, blue
set_luminance ( ) Sets the luminance of a color (range:0-255) based on the values of red, green, blue

Method Details

getNew() public méthode

Allows us to get a new instance by modifying a property of the existing one.
public getNew ( $property = '', $value = '' ) : ariColor | null
$property string can be one of the following: red, green, blue, alpha, hue, saturation, lightness, brightness
$value int|float|string the new value
Résultat ariColor | null

get_mode() public méthode

Figure out what mode we're using.
public get_mode ( string $color ) : string | null
$color string
Résultat string | null

newColor() public static méthode

We use a separate instance per color because there's no need to create a completely new instance each time we call this class. Instead using instances helps us improve performance & footprint.
public static newColor ( $color, $mode = 'auto' ) : ariColor
$color string|array
$mode string
Résultat ariColor (object)

toCSS() public méthode

Returns a CSS-formatted value for colors.
public toCSS ( $mode = 'hex' ) : string
$mode string
Résultat string

Property Details

$alpha public_oe property

public int|float $alpha
Résultat integer | float

$blue public_oe property

public int|double $blue
Résultat integer | double

$brightness public_oe property

public array $brightness
Résultat array

$chroma public_oe property

public int|float $chroma
Résultat integer | float

$color public_oe property

The color as defined in the input
public string|array $color
Résultat string | array

$green public_oe property

public int|double $green
Résultat integer | double

$hex public_oe property

The HEX value of the color.
public string $hex
Résultat string

$hue public_oe property

public int|float $hue
Résultat integer | float

$instances public_oe static_oe property

Each instance is stored as an object in this array. Allows easier access & performance.
public static array $instances
Résultat array

$lightness public_oe property

public int|float $lightness
Résultat integer | float

$luminance public_oe property

public int|float $luminance
Résultat integer | float

$mode public_oe property

The mode of this color (hex/rgb/rgba etc.).
public string $mode
Résultat string

$red public_oe property

public int|double $red
Résultat integer | double

$saturation public_oe property

public int|float $saturation
Résultat integer | float

$word_colors public_oe property

Example: white = #ffffff
public array $word_colors
Résultat array