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
파일 보기 프로젝트 열기: richthegeek/phpsass 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$_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