PHP Class Kirki_Color, kirki

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

Méthodes publiques

Méthode Description
adjust_brightness ( string $hex, integer $steps ) : string Adjusts brightness of the $hex color.
brightness_difference ( string $color_1 = '#ffffff', string $color_2 = '#000000' ) : string This function tries to compare the brightness of the colors.
color_difference ( string $color_1 = '#ffffff', string $color_2 = '#000000' ) : string This is a very simple algorithm that works by summing up the differences between the three color components red, green and blue.
get_alpha_from_rgba ( string $color ) : integer | float Get the alpha channel from an rgba color.
get_brightness ( string $hex ) : integer Gets the brightness of the $hex color.
get_rgb ( string $color, boolean $implode = false ) : array | string Gets the rgb value of a color.
get_rgba ( string $color = '#fff', integer | float $alpha = 1 ) : string Gets the rgba value of the $color.
hex_to_hsv ( string $hex ) : array Convert hex color to hsv.
lumosity_difference ( string $color_1 = '#ffffff', string $color_2 = '#000000' ) : string Uses the luminosity to calculate the difference between the given colors.
mix_colors ( string | false $hex1, string | false $hex2, integer $percentage ) : string Mixes 2 hex colors.
rgb_to_hsv ( string $color = [] ) : array Convert hex color to hsv.
rgba2hex ( string | array $color ) : string A proxy for the sanitize_color method.
rgba_to_rgb ( string $color ) : string Strips the alpha value from an RGBA color string.
sanitize_color ( string | array $color = '', string $mode = 'auto' ) : string Sanitize colors.
sanitize_hex ( string | array $color = '#FFFFFF', boolean $hash = true ) : string A proxy for the sanitize_color method.
sanitize_rgba ( string $color ) : string A proxy the sanitize_color method.

Method Details

adjust_brightness() public static méthode

Adjusts brightness of the $hex color.
public static adjust_brightness ( string $hex, integer $steps ) : string
$hex string The hex value of a color.
$steps integer Should be between -255 and 255. Negative = darker, positive = lighter.
Résultat string Returns hex color.

brightness_difference() public static méthode

A return value of more than 125 is recommended. Combining it with the color_difference function above might make sense.
public static brightness_difference ( string $color_1 = '#ffffff', string $color_2 = '#000000' ) : string
$color_1 string The 1st color.
$color_2 string The 2nd color.
Résultat string

color_difference() public static méthode

A value higher than 500 is recommended for good readability.
public static color_difference ( string $color_1 = '#ffffff', string $color_2 = '#000000' ) : string
$color_1 string The 1st color.
$color_2 string The 2nd color.
Résultat string

get_alpha_from_rgba() public static méthode

Get the alpha channel from an rgba color.
public static get_alpha_from_rgba ( string $color ) : integer | float
$color string The rgba color formatted like rgba(r,g,b,a).
Résultat integer | float The alpha value of the color.

get_brightness() public static méthode

Gets the brightness of the $hex color.
public static get_brightness ( string $hex ) : integer
$hex string The hex value of a color.
Résultat integer Value between 0 and 255.

get_rgb() public static méthode

Gets the rgb value of a color.
public static get_rgb ( string $color, boolean $implode = false ) : array | string
$color string The color.
$implode boolean Whether we want to implode the values or not.
Résultat array | string

get_rgba() public static méthode

Gets the rgba value of the $color.
public static get_rgba ( string $color = '#fff', integer | float $alpha = 1 ) : string
$color string The hex value of a color.
$alpha integer | float Opacity level (0-1).
Résultat string

hex_to_hsv() public static méthode

Convert hex color to hsv.
public static hex_to_hsv ( string $hex ) : array
$hex string The hex value of color 1.
Résultat array Returns array( 'h', 's', 'v' ).

lumosity_difference() public static méthode

The returned value should be bigger than 5 for best readability.
public static lumosity_difference ( string $color_1 = '#ffffff', string $color_2 = '#000000' ) : string
$color_1 string The 1st color.
$color_2 string The 2nd color.
Résultat string

mix_colors() public static méthode

The "percentage" variable is the percent of the first color. to be used it the mix. default is 50 (equal mix).
public static mix_colors ( string | false $hex1, string | false $hex2, integer $percentage ) : string
$hex1 string | false Color.
$hex2 string | false Color.
$percentage integer A value between 0 and 100.
Résultat string Returns hex color.

rgb_to_hsv() public static méthode

Convert hex color to hsv.
public static rgb_to_hsv ( string $color = [] ) : array
$color string The rgb color to convert array( 'r', 'g', 'b' ).
Résultat array Returns array( 'h', 's', 'v' ).

rgba2hex() public static méthode

A proxy for the sanitize_color method.
public static rgba2hex ( string | array $color ) : string
$color string | array The color to convert.
Résultat string The hex value of the color.

rgba_to_rgb() public static méthode

Strips the alpha value from an RGBA color string.
public static rgba_to_rgb ( string $color ) : string
$color string The RGBA color string.
Résultat string The corresponding RGB string.

sanitize_color() public static méthode

Determine if the current value is a hex or an rgba color and call the appropriate method.
Since: 0.8.5
public static sanitize_color ( string | array $color = '', string $mode = 'auto' ) : string
$color string | array The color.
$mode string The mode to be used.
Résultat string

sanitize_hex() public static méthode

A proxy for the sanitize_color method.
public static sanitize_hex ( string | array $color = '#FFFFFF', boolean $hash = true ) : string
$color string | array The color.
$hash boolean Whether we want to include a hash (#) at the beginning or not.
Résultat string The sanitized hex color.

sanitize_rgba() public static méthode

A proxy the sanitize_color method.
public static sanitize_rgba ( string $color ) : string
$color string The color.
Résultat string