PHP Class SassScriptFunctions

A collection of functions for use in SassSCript.
Exibir arquivo Open project: richthegeek/phpsass

Public Properties

Property Type Description
$parser

Public Methods

Method Description
_if ( SassBoolean $condition, mixed $if_true, mixed $if_false ) : mixed An inline "if-else" statement.
abs ( SassNumber $number ) : SassNumber Finds the absolute value of a number.
adjust ( SassColour $colour, SassNumber $amount, boolean $ofCurrent, string $att, boolean $op, float $min, float $max, string $units = '' ) : SassColour Adjusts the colour
adjust_color ( SassColour $color, integer $red, integer $green, integer $blue, integer $hue, integer $saturation, integer $lightness, integer $alpha ) : SassColour Adjusts one or more property of the color by the value requested.
adjust_hue ( SassColour $colour, SassNumber $degrees ) : SassColour Changes the hue of a colour while retaining the lightness and saturation.
alpha ( SassColour $colour ) : SassNumber Returns the alpha component (opacity) of a colour.
append ( $list, $val, $sep = ', ' )
blue ( SassColour $colour ) : SassNumber Returns the blue component of a colour.
ceil ( SassNumber $number ) : SassNumber Rounds a number up to the nearest whole number.
change_color ( SassColour $color, boolean $red = false, boolean $green = false, boolean $blue = false, boolean $hue = false, boolean $saturation = false, boolean $lightness = false, boolean $alpha = false ) : SassColour Changes one or more properties of the color to the requested value
comparable ( SassNumber $number1, SassNumber $number2 ) : SassBoolean Returns true if two numbers are similar enough to be added, subtracted, or compared.
complement ( SassColour $colour ) : SassColour Returns the complement of a colour.
darken ( SassColour $colour, SassNumber $amount, SassBoolean $ofCurrent = false ) : SassColour Makes a colour darker.
desaturate ( SassColour $colour, SassNumber $amount, SassBoolean $ofCurrent = false ) : SassColour Makes a colour less saturated.
fade_in ( SassColour $colour, SassNumber $amount, SassBoolean $ofCurrent = false ) : SassColour Makes a colour more opaque.
fade_out ( SassColour $colour, SassNumber $amount, SassBoolean $ofCurrent = false ) : SassColour Makes a colour more transparent.
floor ( SassNumber $number ) : SassNumber Rounds down to the nearest whole number.
get_var ( $string ) : SassString Returns the variable whose name is the string.
grayscale ( SassColour $colour ) : SassColour Greyscale for non-english speakers.
green ( SassColour $colour ) : SassNumber Returns the green component of a colour.
greyscale ( SassColour $colour ) : SassColour Converts a colour to greyscale.
hsl ( float $h, mixed $s, mixed $l ) : SassColour Creates a SassColour object from hue, saturation, and lightness.
hsla ( SassNumber $h, SassNumber $s, SassNumber $l, float $a ) : SassColour Creates a SassColour object from hue, saturation, lightness and alpha channel (opacity).
hue ( SassColour $colour ) : SassNumber Returns the hue component of a colour.
ie_hex_str ( $color ) returns an IE hex string for a color with an alpha channel suitable for passing to IE filters.
inRange ( float $value, float $min, float $max ) : mixed Ensures the value is within the given range, clipping it if needed.
index ( $list, $value )
invert ( SassColour $colour ) : SassColour: Inverts a colour.
join ( $one, $two, $sep = ', ' )
length ( $list ) : SassNumber Returns the length of the $list
lighten ( SassColour $colour, SassNumber $amount, SassBoolean $ofCurrent = false ) : SassColour Makes a colour lighter.
lightness ( SassColour $colour ) : SassNumber Returns the lightness component of a colour.
max ( )
min ( )
mix ( SassColour $colour1, SassColour $colour2, float $weight = '50%' ) : SassColour Mixes two colours together.
nth ( $list, $n ) : mixed Returns the nth value ofthe $list
opacify ( SassColour $colour, SassNumber $amount, $ofCurrent = false ) : SassColour Makes a colour more opaque.
opacity ( SassColour $colour ) : SassNumber Returns the alpha component (opacity) of a colour.
option ( $name )
percentage ( SassNumber $number ) : SassNumber Converts a decimal number to a percentage.
quote ( string $string ) : SassString Add quotes to a string if the string isn't quoted, or returns the same string if it is.
red ( SassColour $colour ) : SassNumber Returns the red component of a colour.
rgb ( SassNumber $red, SassNumber $green, SassNumber $blue ) : SassColour Creates a SassColour object from red, green, and blue values.
rgba ( ) : SassColour Creates a SassColour object from red, green, and blue values and alpha channel (opacity).
round ( SassNumber $number ) : SassNumber Rounds a number to the nearest whole number.
saturate ( SassColour $colour, SassNumber $amount, $ofCurrent = false ) : SassColour Makes a colour more saturated.
saturation ( SassColour $colour ) : SassNumber Returns the saturation component of a colour.
scale_color ( SassColour $color, integer $red, integer $green, integer $blue, integer $saturation, integer $lightness, integer $alpha ) : SassColour Scales one or more property of the color by the percentage requested.
shade ( SassColour $colour, SassNumber $amount ) : SassColour Changes the shade of a colour, mixing it with the $amount of black.
tint ( SassColour $colour, SassNumber $amount ) : SassColour Changes the tint of a colour, mixing it with the $amount of white.
transparentize ( SassColour $colour, SassNumber $amount, $ofCurrent = false ) : SassColour Makes a colour more transparent.
type_of ( SassLiteral $obj ) : SassString Inspects the type of the argument, returning it as an unquoted string.
unit ( SassNumber $number ) : SassString Inspects the unit of the number, returning it as a quoted string.
unitless ( SassNumber $number ) : SassBoolean Inspects the unit of the number, returning a boolean indicating if it is unitless.
units ( SassNumber $number ) : SassString Inspects the units of the number, returning it as a quoted string.
unquote ( string $string ) : SassString Removes quotes from a string if the string is quoted, or returns the same string if it's not.
zip ( ) New function zip allows several lists to be combined into one list of lists. For example: zip(1px 1px 3px, solid dashed solid, red green blue) becomes 1px solid red, 1px dashed green, 3px solid blue

Method Details

_if() public static method

An inline "if-else" statement.
public static _if ( SassBoolean $condition, mixed $if_true, mixed $if_false ) : mixed
$condition SassBoolean - values are loosely-evaulated by PHP, so 'false' includes null, false, 0, ''
$if_true mixed returns if Condition is true
$if_false mixed returns if Condition is false
return mixed

abs() public static method

For example: abs(10px) => 10px abs(-10px) => 10px
public static abs ( SassNumber $number ) : SassNumber
$number SassNumber number to round
return SassNumber The absolute value of the number

adjust() public static method

Adjusts the colour
public static adjust ( SassColour $colour, SassNumber $amount, boolean $ofCurrent, string $att, boolean $op, float $min, float $max, string $units = '' ) : SassColour
$colour SassColour the colour to adjust
$amount SassNumber the amount to adust by
$ofCurrent boolean whether the amount is a proportion of the current value or the total range
$att string the attribute to adjust
$op boolean whether to decrease (false) or increase (true) the value of the attribute
$min float minimum value the amount can be
$max float maximum value the amount can bemixed
$units string amount units
return SassColour

adjust_color() public static method

Adjusts one or more property of the color by the value requested.
public static adjust_color ( SassColour $color, integer $red, integer $green, integer $blue, integer $hue, integer $saturation, integer $lightness, integer $alpha ) : SassColour
$color SassColour the colour to adjust
$red integer
$green integer
$blue integer
$hue integer
$saturation integer
$lightness integer
$alpha integer
return SassColour

adjust_hue() public static method

Changes the hue of a colour while retaining the lightness and saturation.
public static adjust_hue ( SassColour $colour, SassNumber $degrees ) : SassColour
$colour SassColour The colour to adjust
$degrees SassNumber The amount to adjust the colour by
return SassColour The adjusted colour

alpha() public static method

Returns the alpha component (opacity) of a colour.
public static alpha ( SassColour $colour ) : SassNumber
$colour SassColour The colour
return SassNumber The alpha component (opacity) of colour

append() public static method

public static append ( $list, $val, $sep = ', ' )

blue() public static method

Returns the blue component of a colour.
public static blue ( SassColour $colour ) : SassNumber
$colour SassColour The colour
return SassNumber The blue component of colour

ceil() public static method

For example: ceil(10.4px) => 11px ceil(10.6px) => 11px
public static ceil ( SassNumber $number ) : SassNumber
$number SassNumber The number to round
return SassNumber The rounded number

change_color() public static method

Changes one or more properties of the color to the requested value
public static change_color ( SassColour $color, boolean $red = false, boolean $green = false, boolean $blue = false, boolean $hue = false, boolean $saturation = false, boolean $lightness = false, boolean $alpha = false ) : SassColour
$color SassColour the color to change
$red boolean
$green boolean
$blue boolean
$hue boolean
$saturation boolean
$lightness boolean
$alpha boolean
return SassColour

comparable() public static method

Returns true if two numbers are similar enough to be added, subtracted, or compared.
public static comparable ( SassNumber $number1, SassNumber $number2 ) : SassBoolean
$number1 SassNumber The first number to test
$number2 SassNumber The second number to test
return SassBoolean True if the numbers are similar

complement() public static method

Rotates the hue by 180 degrees.
public static complement ( SassColour $colour ) : SassColour
$colour SassColour The colour
return SassColour The comlemented colour

darken() public static method

Makes a colour darker.
See also: adjust
public static darken ( SassColour $colour, SassNumber $amount, SassBoolean $ofCurrent = false ) : SassColour
$colour SassColour The colour to darken
$amount SassNumber The amount to darken the colour by
$ofCurrent SassBoolean Whether the amount is a proportion of the current value (true) or the total range (false). The default is false - the amount is a proportion of the total range. If the colour lightness value is 80% and the amount is 50%, the resulting colour lightness value is 30% if the amount is a proportion of the total range, whereas it is 40% if the amount is a proportion of the current value.
return SassColour The darkened colour

desaturate() public static method

Makes a colour less saturated.
See also: adjust
public static desaturate ( SassColour $colour, SassNumber $amount, SassBoolean $ofCurrent = false ) : SassColour
$colour SassColour The colour to desaturate
$amount SassNumber The amount to desaturate the colour by
$ofCurrent SassBoolean Whether the amount is a proportion of the current value (true) or the total range (false). The default is false - the amount is a proportion of the total range. If the colour saturation value is 80% and the amount is 50%, the resulting colour saturation value is 30% if the amount is a proportion of the total range, whereas it is 40% if the amount is a proportion of the current value.
return SassColour The desaturateed colour

fade_in() public static method

Alias for {@link opacify}.
See also: opacify
public static fade_in ( SassColour $colour, SassNumber $amount, SassBoolean $ofCurrent = false ) : SassColour
$colour SassColour The colour to opacify
$amount SassNumber The amount to opacify the colour by
$ofCurrent SassBoolean Whether the amount is a proportion of the current value (true) or the total range (false).
return SassColour The opacified colour

fade_out() public static method

Alias for {@link transparentize}.
See also: transparentize
public static fade_out ( SassColour $colour, SassNumber $amount, SassBoolean $ofCurrent = false ) : SassColour
$colour SassColour The colour to transparentize
$amount SassNumber The amount to transparentize the colour by
$ofCurrent SassBoolean Whether the amount is a proportion of the current value (true) or the total range (false).
return SassColour The transparentized colour

floor() public static method

For example: floor(10.4px) => 10px floor(10.6px) => 10px
public static floor ( SassNumber $number ) : SassNumber
$number SassNumber The number to round
return SassNumber The rounded number

get_var() public static method

Returns the variable whose name is the string.
public static get_var ( $string ) : SassString
return SassString

grayscale() public static method

Greyscale for non-english speakers.
See also: desaturate
public static grayscale ( SassColour $colour ) : SassColour
$colour SassColour The colour
return SassColour The greyscale colour

green() public static method

Returns the green component of a colour.
public static green ( SassColour $colour ) : SassNumber
$colour SassColour The colour
return SassNumber The green component of colour

greyscale() public static method

Reduces the saturation to zero.
See also: desaturate
public static greyscale ( SassColour $colour ) : SassColour
$colour SassColour The colour
return SassColour The greyscale colour

hsl() public static method

Uses the algorithm from the {@link http://www.w3.org/TR/css3-colour/#hsl-colour CSS3 spec}.
public static hsl ( float $h, mixed $s, mixed $l ) : SassColour
$h float The hue of the colour in degrees. Should be between 0 and 360 inclusive
$s mixed The saturation of the colour as a percentage. Must be between '0%' and 100%, inclusive
$l mixed The lightness of the colour as a percentage. Must be between 0% and 100%, inclusive
return SassColour The resulting colour

hsla() public static method

Creates a SassColour object from hue, saturation, lightness and alpha channel (opacity).
public static hsla ( SassNumber $h, SassNumber $s, SassNumber $l, float $a ) : SassColour
$h SassNumber The hue of the colour in degrees. Should be between 0 and 360 inclusive
$s SassNumber The saturation of the colour as a percentage. Must be between 0% and 100% inclusive
$l SassNumber The lightness of the colour as a percentage. Must be between 0% and 100% inclusive
$a float The alpha channel. A number between 0 and 1.
return SassColour The resulting colour

hue() public static method

Returns the hue component of a colour.
public static hue ( SassColour $colour ) : SassNumber
$colour SassColour The colour
return SassNumber The hue component of colour

ie_hex_str() public static method

returns an IE hex string for a color with an alpha channel suitable for passing to IE filters.
public static ie_hex_str ( $color )

inRange() public static method

Ensures the value is within the given range, clipping it if needed.
public static inRange ( float $value, float $min, float $max ) : mixed
$value float the value to test
$min float the minimum value
$max float the maximum value
return mixed the value clipped to the range

index() public static method

public static index ( $list, $value )

invert() public static method

The red, green, and blue values are inverted value = (255 - value)
public static invert ( SassColour $colour ) : SassColour:
$colour SassColour the colour
return SassColour:

join() public static method

public static join ( $one, $two, $sep = ', ' )

length() public static method

Returns the length of the $list
public static length ( $list ) : SassNumber
return SassNumber

lighten() public static method

Makes a colour lighter.
See also: lighten_rel
public static lighten ( SassColour $colour, SassNumber $amount, SassBoolean $ofCurrent = false ) : SassColour
$colour SassColour The colour to lighten
$amount SassNumber The amount to lighten the colour by
$ofCurrent SassBoolean Whether the amount is a proportion of the current value (true) or the total range (false). The default is false - the amount is a proportion of the total range. If the colour lightness value is 40% and the amount is 50%, the resulting colour lightness value is 90% if the amount is a proportion of the total range, whereas it is 60% if the amount is a proportion of the current value.
return SassColour The lightened colour

lightness() public static method

Returns the lightness component of a colour.
public static lightness ( SassColour $colour ) : SassNumber
$colour SassColour The colour
return SassNumber The lightness component of colour

max() public static method

public static max ( )

min() public static method

public static min ( )

mix() public static method

Takes the average of each of the RGB components, optionally weighted by the given percentage. The opacity of the colours is also considered when weighting the components. The weight specifies the amount of the first colour that should be included in the returned colour. The default, 50%, means that half the first colour and half the second colour should be used. 25% means that a quarter of the first colour and three quarters of the second colour should be used. For example: mix(#f00, #00f) => #7f007f mix(#f00, #00f, 25%) => #3f00bf mix(rgba(255, 0, 0, 0.5), #00f) => rgba(63, 0, 191, 0.75)
public static mix ( SassColour $colour1, SassColour $colour2, float $weight = '50%' ) : SassColour
$colour1 SassColour The first colour
$colour2 SassColour The second colour
$weight float Percentage of the first colour to use
return SassColour The mixed colour

nth() public static method

Returns the nth value ofthe $list
public static nth ( $list, $n ) : mixed
return mixed

opacify() public static method

Makes a colour more opaque.
See also: opacify_rel
public static opacify ( SassColour $colour, SassNumber $amount, $ofCurrent = false ) : SassColour
$colour SassColour The colour to opacify
$amount SassNumber The amount to opacify the colour by If this is a unitless number between 0 and 1 the adjustment is absolute, if it is a percentage the adjustment is relative. If the colour alpha value is 0.4 if the amount is 0.5 the resulting colour alpha value is 0.9, whereas if the amount is 50% the resulting colour alpha value is 0.6.
return SassColour The opacified colour

opacity() public static method

Returns the alpha component (opacity) of a colour.
public static opacity ( SassColour $colour ) : SassNumber
$colour SassColour The colour
return SassNumber The alpha component (opacity) of colour

option() public static method

public static option ( $name )

percentage() public static method

For example: percentage(100px / 50px) => 200%
public static percentage ( SassNumber $number ) : SassNumber
$number SassNumber The decimal number to convert to a percentage
return SassNumber The number as a percentage

quote() public static method

Add quotes to a string if the string isn't quoted, or returns the same string if it is.
See also: unquote
public static quote ( string $string ) : SassString
$string string String to quote
return SassString Quoted string

red() public static method

Returns the red component of a colour.
public static red ( SassColour $colour ) : SassNumber
$colour SassColour The colour
return SassNumber The red component of colour

rgb() public static method

Creates a SassColour object from red, green, and blue values.
public static rgb ( SassNumber $red, SassNumber $green, SassNumber $blue ) : SassColour
$red SassNumber the red component. A number between 0 and 255 inclusive, or between 0% and 100% inclusive
$green SassNumber the green component. A number between 0 and 255 inclusive, or between 0% and 100% inclusive
$blue SassNumber the blue component. A number between 0 and 255 inclusive, or between 0% and 100% inclusive
return SassColour new SassColour SassColour object

rgba() public static method

There are two overloads: * rgba(red, green, blue, alpha)
public static rgba ( ) : SassColour
return SassColour new SassColour SassColour object

round() public static method

For example: round(10.4px) => 10px round(10.6px) => 11px
public static round ( SassNumber $number ) : SassNumber
$number SassNumber The number to round
return SassNumber The rounded number

saturate() public static method

Makes a colour more saturated.
See also: adjust
public static saturate ( SassColour $colour, SassNumber $amount, $ofCurrent = false ) : SassColour
$colour SassColour The colour to saturate
$amount SassNumber The amount to saturate the colour by
return SassColour The saturated colour

saturation() public static method

Returns the saturation component of a colour.
public static saturation ( SassColour $colour ) : SassNumber
$colour SassColour The colour
return SassNumber The saturation component of colour

scale_color() public static method

Scales one or more property of the color by the percentage requested.
public static scale_color ( SassColour $color, integer $red, integer $green, integer $blue, integer $saturation, integer $lightness, integer $alpha ) : SassColour
$color SassColour the colour to adjust
$red integer
$green integer
$blue integer
$saturation integer
$lightness integer
$alpha integer
return SassColour

shade() public static method

Changes the shade of a colour, mixing it with the $amount of black.
public static shade ( SassColour $colour, SassNumber $amount ) : SassColour
$colour SassColour The colour to adjust
$amount SassNumber The amount of black to mix with the $colour
return SassColour The adjusted colour

tint() public static method

Changes the tint of a colour, mixing it with the $amount of white.
public static tint ( SassColour $colour, SassNumber $amount ) : SassColour
$colour SassColour The colour to adjust
$amount SassNumber The amount of white to mix with the $colour
return SassColour The adjusted colour

transparentize() public static method

Makes a colour more transparent.
public static transparentize ( SassColour $colour, SassNumber $amount, $ofCurrent = false ) : SassColour
$colour SassColour The colour to transparentize
$amount SassNumber The amount to transparentize the colour by. If this is a unitless number between 0 and 1 the adjustment is absolute, if it is a percentage the adjustment is relative. If the colour alpha value is 0.8 if the amount is 0.5 the resulting colour alpha value is 0.3, whereas if the amount is 50% the resulting colour alpha value is 0.4.
return SassColour The transparentized colour

type_of() public static method

Inspects the type of the argument, returning it as an unquoted string.
public static type_of ( SassLiteral $obj ) : SassString
$obj SassLiteral The object to inspect
return SassString The type of object

unit() public static method

Alias for units.
See also: units
public static unit ( SassNumber $number ) : SassString
$number SassNumber The number to inspect
return SassString The units of the number

unitless() public static method

Inspects the unit of the number, returning a boolean indicating if it is unitless.
public static unitless ( SassNumber $number ) : SassBoolean
$number SassNumber The number to inspect
return SassBoolean True if the number is unitless, false if it has units.

units() public static method

Inspects the units of the number, returning it as a quoted string.
public static units ( SassNumber $number ) : SassString
$number SassNumber The number to inspect
return SassString The units of the number

unquote() public static method

Removes quotes from a string if the string is quoted, or returns the same string if it's not.
See also: quote
public static unquote ( string $string ) : SassString
$string string String to unquote
return SassString Unuoted string

zip() public method

New function zip allows several lists to be combined into one list of lists. For example: zip(1px 1px 3px, solid dashed solid, red green blue) becomes 1px solid red, 1px dashed green, 3px solid blue
public zip ( )

Property Details

$parser public_oe static_oe property

public static $parser