Class: Color

SQR.Color(ropt, gopt, bopt, aopt)

new Color(ropt, gopt, bopt, aopt)

Parameters:
Name Type Attributes Description
r Number <optional>

the red component of the color

g Number <optional>

the green component of the color

b Number <optional>

the blue component of the color

a Number <optional>

the transparency (alpha) component of the color

Source:

Methods

clone() → {Object}

creates a copy of the color instance

Source:
Returns:

a new SQR.Color instance

Type
Object

lerp(a, b, t) → {Object}

performs a linear interpolation between two colors and stores the value in the color instance

Parameters:
Name Type Description
a SQR.Color

the first color to use in interpolation

b SQR.Color

the second color to use in interpolation

t Number

the interpolation value [0-1]

Source:
Returns:

reference to this SQR.Color instance, for chaining

Type
Object

lighten()

modfies the color values to make them darker of lighter in a more fance way than a simple multiplication. However this is not currently implemented so for now it really does the same thing as SQR.Color.mul.

<p>Here's <a href='http://stackoverflow.com/questions/141855/programmatically-lighten-a-color'>some info on how to implement this properly</a>.</p>
Source:

mul(v) → {Object}

modfies the color values to make it darker of lighter

Parameters:
Name Type Description
v Number

the amount by which to change the color (1 will leave it as it, > 1 will lightned, < 1 will darken the color)

Source:
Returns:

reference to this SQR.Color instance, for chaining

Type
Object

setHex(hex) → {Object}

sets the color component values from a hex string (ex. #a4d278) or number (ex. 0xa4d278) Useful when copying color vaues from ex. Photoshop.

Parameters:
Name Type Description
hex string | Number

the hex color values as string (ex. #a4d278) or number (ex. 0xa4d278)

Source:
Returns:

reference to this SQR.Color instance, for chaining

Type
Object

setRGB(ropt, gopt, bopt) → {Object}

sets the color component values.

Parameters:
Name Type Attributes Description
r Number <optional>

the red component of the color

g Number <optional>

the green component of the color

b Number <optional>

the blue component of the color

Source:
Returns:

reference to this SQR.Color instance, for chaining

Type
Object

setRGB(oc) → {Object}

copies the color component values from another instance of SQR.Color

Parameters:
Name Type Description
oc SQR.Color

the color instance to copy from

Source:
Returns:

reference to this SQR.Color instance, for chaining

Type
Object

toCSS() → {string}

Source:
Returns:

a CSS friendly string representing the color. The format used is rgb(r, g, b).

Type
string