Skip to content
agatronic edited this page Jun 3, 2012 · 5 revisions

Functions

Color Functions

alpha

alpha(color, [amount])

Returns or modifies the alpha of a color

blue

blue(color, [amount])

Returns or modifies the blue component of a color.

Not supported by less.js

color

color(string)

Converts a color string (e.g. “#33aaee”) to a color.

complement

complement(color)

Returns the complement of a color.

Not supported by less.js

contrast

contrast(color, [light=white], [dark=black], [threshold=0.5])

Returns either `light` or `dark` , depending on the lightness of `color`.

Not supported by less.js

darken

darken(color, amount)

Modifies the brightness of a color (negative – see lighten).

desaturate

desaturate(color, amount)

Modifies the saturation of a color (negative – see saturate).

grayscale/greyscale

grayscale(color)
greyscale(color)

Converts a color to grayscale.

grayscale not supported by less.js

green

green(color, [amount])

Returns or modifies the green component of a color.

Not supported by less.js

hsl

hsl(hue, saturation, lightness)

Returns a color with the specified hue, saturation and lightness components

hsla

hsla(hue, saturation, lightness, alpha)

Returns a color with the specified hue, saturation, lightness and alpha components

hue

hue(color, [amount])

Returns or modifies the hue of a color.

Modifying the hue is not supported by less.js

lighten

lighten(color, amount)

Modifies the brightness of a color (positive – see darken).

lightness

lightness(color, [amount])

Returns or modifies the brightness of a color.

Modifying the hue is not supported by less.js

mix

mix(color1, color2, [weight = 50%])

Mix two colors together

red

red(color, [amount])

Returns or modifies the red component of a color.

Not supported by less.js

rgb

rgb(red, green, blue)

Returns a color with the specified red, green and blue components

rgba(r,g,b,a)

rgba(r,g,b,a)(red, green, blue, alpha)

Returns a color with the specified red, green, blue and alpha components

rgba(c,a)

rgba(c,a)(color, alpha)

Changes the alpha component of the specified color.

saturate

saturate(color, amount)

Modifies the saturation of a color (positive – see desaturate).

saturation

saturation(color, [amount])

Returns or modifies the saturation of a color.

Modifying is not supported by less.js

spin

spin(color, amount)

Modifies the hue of a color (same as hue).

Not supported by less.js

Number Functions

abs

abs(number)

returns the absolute of a number

Not supported by less.js

add

add(number1, [number2, [number3...]])

Adds together all the parameters and returns the result.

ceil

ceil(number)

Returns the ceiling of a number (e.g. 1.1 => 2)

floor

floor(number)

Returns the floor of a number (e.g. 1.8 => 1)

hex

hex(number)

Returns the hex version of a number. Note that the number will be clamped to one between 0 and 255.

increment

increment(number)

Adds 1 onto the number and returns it

percentage

percentage(number)

Returns the number as a percentage. e.g. percentage(30%) => 30%, percentage(0.3) => 30%

pow

pow(number, number)

Calculates the power, e.g. pow(2,3) => 8

Not supported by less.js

round

round(number)

Rounds the number, e.g. round(1.4) => 1, round(1.6) => 2

String Functions

%

%(string, args...)

Specify a string using C format identifiers, e.g. %d, %s, %a and the args will be filled into the placeholders.

Consider using string interpolation instead (e.g. “…@{variable}…”)

e

e(string)

Removes the quotes from a string, e.g. e(“string”) => string

If the string is explicit, consider using ~ in front of the string to remove the quotes instead (e.g. ~“string” => string).

formatstring

formatstring(string, args...)

the equivalent of the C# format string. Consider using string interpolation.

Is Functions

iscolor

iscolor(anything)

returns true if the parameter is a color, otherwise it returns false

isem

isem(anything)

returns true if the parameter is in the em unit, otherwise it returns false

iskeyword

iskeyword(anything)

returns true if the parameter is a color, otherwise it returns false

isnumber

isnumber(anything)

returns true if the parameter is a number, otherwise it returns false

ispercentage

ispercentage(anything)

returns true if the parameter is in the % unit, otherwise it returns false

ispixel

ispixel(anything)

returns true if the parameter is in the px unit, otherwise it returns false

isstring

isstring(anything)

returns true if the parameter is a string, otherwise it returns false

isurl

isurl(anything)

returns true if the parameter is a url, otherwise it returns false