Blesta Source Documentation

Color extends Helper

Color helper

Create color contrasts and convert color values to various formats

Table of Contents

Properties

$components
$helpers
$models
$color

Methods

__construct()
asHex() Convert the internal color to hex
asHtml() Convert the internal color to HTML hex color
asRgb() Convert the internal color to an rgb array
contrast50() Finds the constrast of the current color using the 50/50 method then sets it as the internal color
contrastYiq() Finds the constrast of the current color in YIQ space then sets it as the internal color
hex() Sets the current color to the given hex or HTML hex value
rgb() Sets the current color to the given RGB value
toRgb() Convert a color from one format to rgb
Properties

$color

private array<string|int, mixed> $color = [0, 0, 0]

A representation of the current color

Methods

__construct()

public __construct() : mixed

asHex()

Convert the internal color to hex

public asHex() : string
Return values
string

The hex color for the current color

asHtml()

Convert the internal color to HTML hex color

public asHtml() : string
Return values
string

The HTML hex color for the current color

asRgb()

Convert the internal color to an rgb array

public asRgb() : array<string|int, mixed>
Return values
array<string|int, mixed>

The rgb color for the current color

contrast50()

Finds the constrast of the current color using the 50/50 method then sets it as the internal color

public contrast50() : Color
Return values
Color

$this

contrastYiq()

Finds the constrast of the current color in YIQ space then sets it as the internal color

public contrastYiq() : Color
Return values
Color

$this

hex()

Sets the current color to the given hex or HTML hex value

public hex(string $color) : Color
Parameters
$color : string

The given color in hex or HTMl hex value

Return values
Color

$this

rgb()

Sets the current color to the given RGB value

public rgb(array<string|int, mixed> $color) : Color
Parameters
$color : array<string|int, mixed>

The given color in a numerically indexed array where index 0 is red, index 1 is green, index 2 is blue

Return values
Color

$this

toRgb()

Convert a color from one format to rgb

private toRgb(mixed $color[, string $from = 'hex' ]) : array<string|int, mixed>
Parameters
$color : mixed

The color to make rgb

$from : string = 'hex'

The format to convert from

Return values
array<string|int, mixed>

An rgb array

Tags
subpackage

helpers.color


        
On this page

Search results