PHP Класс SassColour

Provides operations and type testing for Sass colours. Colour operations are all piecewise, e.g. when adding two colours each component is added independantly; Rr = R1 + R2, Gr = G1 + G2, Br = B1 + B2. Resulting colours are returned as a named colour if possible or #rrggbb. Transparent is a SassColour. Operations on transparent return transparent.
Наследование: extends SassLiteral
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$_html4Colours reverse array (value => name) of named HTML4 colours
$_svgColours reverse array (value => name) of named SVG1.0 colours
$alpha alpha component. 0 - 1
$blue blue component. 0 - 255
$green green component. 0 - 255
$hsl HSL colour components. Used to check for HSL attributes.
$hue hue component. 0 - 360
$lightness lightness component. 0 - 100
$red red component. 0 - 255
$regex
$rgb RGB colour components. Used to check for RGB attributes.
$saturation saturation component. 0 - 100
$svgColours

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

Метод Описание
__construct ( mixed $colour ) : SassColour Constructs an RGB or HSL color object, optionally with an alpha channel.
asHex ( $inc_hash = TRUE )
assertValid ( array $colour, boolean $all = true ) : string Asserts that the colour space is valid.
getAlpha ( boolean $value = false ) : float Returns the alpha component (opacity) of this colour.
getBlue ( boolean $value = false ) : integer Returns the blue component of this colour.
getGreen ( boolean $value = false ) : integer Returns the green component of this colour.
getHsl ( ) : array Returns an array with the HSL components of this colour.
getHsla ( ) : array Returns an array with the HSL and alpha components of this colour.
getHue ( boolean $value = false ) : float Returns the hue of this colour.
getLightness ( boolean $value = false ) : float Returns the lightness of this colour.
getRed ( boolean $value = false ) : integer Returns the red component of this colour.
getRgb ( ) : array Returns an array with the RGB components of this colour.
getRgba ( ) : array Returns an array with the RGB and alpha components of this colour.
getSaturation ( boolean $value = false ) : float Returns the saturation of this colour.
getValue ( ) : array Returns the value of this colour.
hsl2rgb ( ) Converts from HSL to RGB colourspace Algorithm from the CSS3 spec: {@link http://www.w3.org/TR/css3-color/#hsl-color}
hue2rgb ( $p, $q, $t ) Converts from hue to RGB colourspace
isTranslucent ( ) : boolean Returns whether this colour object is translucent; that is, whether the alpha channel is non-1.
isa ( string $subject ) : mixed Returns a value indicating if a token of this type can be matched at the start of the subject string.
length ( )
nth ( $i )
op_bw_and ( mixed $other ) : sassColour Colour bitwise AND
op_bw_or ( mixed $other ) : sassColour Colour bitwise OR
op_bw_xor ( mixed $other ) : sassColour Colour bitwise XOR
op_div ( mixed $other ) : sassColour Colour division
op_minus ( mixed $other ) : sassColour Colour subraction
op_modulo ( mixed $other ) : sassColour Colour modulus
op_not ( ) : sassColour Colour bitwise NOT
op_plus ( $other ) : sassColour Colour addition
op_shiftl ( sassNumber $other ) : sassColour Colour bitwise Shift Left
op_shiftr ( sassNumber $other ) : sassColour Colour bitwise Shift Right
op_times ( $other ) : sassColour Colour multiplication
rgb2hsl ( ) Converts from RGB to HSL colourspace Algorithm adapted from {@link http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript}
toString ( boolean $css3 = true ) : string Converts the colour to a string.
with ( array $attributes ) Returns a copy of this colour with one or more channels changed.

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

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

RGB values must be between 0 and 255. Saturation and lightness values must be between 0 and 100. The alpha value must be between 0 and 1. The colour can be specified as: + a string that is an SVG colour or of the form #rgb or #rrggbb + an array with either 'red', 'green', and 'blue' keys, and optionally an alpha key. + an array with 'hue', 'saturation', and 'lightness' keys, and optionally an alpha key. + an array of red, green, and blue values, and optionally an alpha value.
public __construct ( mixed $colour ) : SassColour
$colour mixed the colour
Результат SassColour

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

public asHex ( $inc_hash = TRUE )

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

Returns the name of the colour space: 'rgb' if red, green, or blue keys given; 'hsl' if hue, saturation or lightness keys given; null if a non-associative array
public assertValid ( array $colour, boolean $all = true ) : string
$colour array the colour to test
$all boolean whether all colour space keys must be given
Результат string name of the colour space

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

Returns the alpha component (opacity) of this colour.
public getAlpha ( boolean $value = false ) : float
$value boolean
Результат float the alpha component (opacity) of this colour.

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

Returns the blue component of this colour.
public getBlue ( boolean $value = false ) : integer
$value boolean
Результат integer the blue component of this colour.

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

Returns the green component of this colour.
public getGreen ( boolean $value = false ) : integer
$value boolean
Результат integer the green component of this colour.

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

Returns an array with the HSL components of this colour.
public getHsl ( ) : array
Результат array the HSL components of this colour

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

Returns an array with the HSL and alpha components of this colour.
public getHsla ( ) : array
Результат array the HSL and alpha components of this colour

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

Returns the hue of this colour.
public getHue ( boolean $value = false ) : float
$value boolean
Результат float the hue of this colour.

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

Returns the lightness of this colour.
public getLightness ( boolean $value = false ) : float
$value boolean
Результат float the lightness of this colour.

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

Returns the red component of this colour.
public getRed ( boolean $value = false ) : integer
$value boolean
Результат integer the red component of this colour.

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

Returns an array with the RGB components of this colour.
public getRgb ( ) : array
Результат array the RGB components of this colour

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

Returns an array with the RGB and alpha components of this colour.
public getRgba ( ) : array
Результат array the RGB and alpha components of this colour

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

Returns the saturation of this colour.
public getSaturation ( boolean $value = false ) : float
$value boolean
Результат float the saturation of this colour.

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

Returns the value of this colour.
Устаревший:
public getValue ( ) : array
Результат array the colour

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

Converts from HSL to RGB colourspace Algorithm from the CSS3 spec: {@link http://www.w3.org/TR/css3-color/#hsl-color}
public hsl2rgb ( )

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

Converts from hue to RGB colourspace
public hue2rgb ( $p, $q, $t )

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

Returns whether this colour object is translucent; that is, whether the alpha channel is non-1.
public isTranslucent ( ) : boolean
Результат boolean true if this colour is translucent, false if not

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

Returns a value indicating if a token of this type can be matched at the start of the subject string.
public static isa ( string $subject ) : mixed
$subject string the subject string
Результат mixed match at the start of the string or false if no match

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

public length ( )

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

public nth ( $i )

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

Colour bitwise AND
public op_bw_and ( mixed $other ) : sassColour
$other mixed value (SassColour or SassNumber) to bitwise AND with
Результат sassColour the colour result

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

Colour bitwise OR
public op_bw_or ( mixed $other ) : sassColour
$other mixed value (SassColour or SassNumber) to bitwise OR with
Результат sassColour the colour result

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

Colour bitwise XOR
public op_bw_xor ( mixed $other ) : sassColour
$other mixed value (SassColour or SassNumber) to bitwise XOR with
Результат sassColour the colour result

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

Colour division
public op_div ( mixed $other ) : sassColour
$other mixed value (SassColour or SassNumber) to divide by
Результат sassColour the colour result

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

Colour subraction
public op_minus ( mixed $other ) : sassColour
$other mixed value (SassColour or SassNumber) to subtract
Результат sassColour the colour result

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

Colour modulus
public op_modulo ( mixed $other ) : sassColour
$other mixed value (SassColour or SassNumber) to divide by
Результат sassColour the colour result

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

Colour bitwise NOT
public op_not ( ) : sassColour
Результат sassColour the colour result

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

Colour addition
public op_plus ( $other ) : sassColour
Результат sassColour the colour result

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

Colour bitwise Shift Left
public op_shiftl ( sassNumber $other ) : sassColour
$other sassNumber amount to shift left by
Результат sassColour the colour result

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

Colour bitwise Shift Right
public op_shiftr ( sassNumber $other ) : sassColour
$other sassNumber amount to shift right by
Результат sassColour the colour result

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

Colour multiplication
public op_times ( $other ) : sassColour
Результат sassColour the colour result

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

Converts from RGB to HSL colourspace Algorithm adapted from {@link http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript}
public rgb2hsl ( )

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

Converts the colour to a string.
public toString ( boolean $css3 = true ) : string
$css3 boolean whether to use CSS3 SVG1.0 colour names
Результат string the colour as a named colour, rgba(r,g,g,a) or #rrggbb

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

RGB or HSL attributes may be changed, but not both at once.
public with ( array $attributes )
$attributes array attributes to change

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

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

reverse array (value => name) of named HTML4 colours
public static $_html4Colours

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

reverse array (value => name) of named SVG1.0 colours
public static $_svgColours

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

alpha component. 0 - 1
public $alpha

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

blue component. 0 - 255
public $blue

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

green component. 0 - 255
public $green

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

HSL colour components. Used to check for HSL attributes.
public static $hsl

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

hue component. 0 - 360
public $hue

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

lightness component. 0 - 100
public $lightness

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

red component. 0 - 255
public $red

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

public static $regex

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

RGB colour components. Used to check for RGB attributes.
public static $rgb

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

saturation component. 0 - 100
public $saturation

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

public static $svgColours