PHP Класс ariColor, kirki

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
__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

Описание методов

getNew() публичный Метод

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
Результат ariColor | null

get_mode() публичный Метод

Figure out what mode we're using.
public get_mode ( string $color ) : string | null
$color string
Результат string | null

newColor() публичный статический Метод

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
Результат ariColor (object)

toCSS() публичный Метод

Returns a CSS-formatted value for colors.
public toCSS ( $mode = 'hex' ) : string
$mode string
Результат string

Описание свойств

$alpha публичное свойство

public int|float $alpha
Результат integer | float

$blue публичное свойство

public int|double $blue
Результат integer | double

$brightness публичное свойство

public array $brightness
Результат array

$chroma публичное свойство

public int|float $chroma
Результат integer | float

$color публичное свойство

The color as defined in the input
public string|array $color
Результат string | array

$green публичное свойство

public int|double $green
Результат integer | double

$hex публичное свойство

The HEX value of the color.
public string $hex
Результат string

$hue публичное свойство

public int|float $hue
Результат integer | float

$instances публичное статическое свойство

Each instance is stored as an object in this array. Allows easier access & performance.
public static array $instances
Результат array

$lightness публичное свойство

public int|float $lightness
Результат integer | float

$luminance публичное свойство

public int|float $luminance
Результат integer | float

$mode публичное свойство

The mode of this color (hex/rgb/rgba etc.).
public string $mode
Результат string

$red публичное свойство

public int|double $red
Результат integer | double

$saturation публичное свойство

public int|float $saturation
Результат integer | float

$word_colors публичное свойство

Example: white = #ffffff
public array $word_colors
Результат array