Rac. Color

Color with RBGA values, each one on the [0,1] range.

Constructor

new Color(rac, r, g, b, aopt)

# | source: style/Color.js, line 13

Creates a new Color instance.

Parameters:
Name Type Attributes Default Description
rac Rac

Instance to use for drawing and creating other objects

r number

The red channel value, in the [0,1] range

g number

The green channel value, in the [0,1] range

b number

The blue channel value, in the [0,1] range

a number <optional>
1

The alpha channel value, in the [0,1] range

Members

a :number

# | source: style/Color.js, line 58

The alpha channel of the color, in the [0,1] range.

b :number

# | source: style/Color.js, line 52

The blue channel of the color, in the [0,1] range.

g :number

# | source: style/Color.js, line 46

The green channel of the color, in the [0,1] range.

r :number

# | source: style/Color.js, line 40

The red channel of the color, in the [0,1] range.

rac :Rac

# | source: style/Color.js, line 34

Instance of Rac used for drawing and passed along to any created object.

Methods

(static) fromHex(rac, hexString) → {Rac.Color}

Creates a new Color instance from a hexadecimal triplet string.

The hexString is expected to have 6 digits and can optionally start with #. AABBCC and #DDEEFF are both valid inputs, the three digit shorthand is not yet supported.

An error is thrown if hexString is misformatted or cannot be parsed.

Parameters:
Name Type Description
rac Rac

Instance to use for drawing and creating other objects

hexString string

The RGB hex triplet to interpret

(static) fromRgba(rac, r, g, b, aopt) → {Rac.Color}

# | source: style/Color.js, line 84

Creates a new Color instance with each channel received in the [0,255] range

Parameters:
Name Type Attributes Default Description
rac Rac

Instance to use for drawing and creating other objects

r number

The red channel value, in the [0,255] range

g number

The green channel value, in the [0,255] range

b number

The blue channel value, in the [0,255] range

a number <optional>
255

The alpha channel value, in the [0,255] range

fill() → {Rac.Fill}

Returns a new Fill that uses this as color.

linearTransition(ratio, target) → {Rac.Color}

Returns a new Color in the linear transition between this and target at a ratio in the range [0,1].

When ratio is 0 or less the new Color is equivalent to this, when ratio is 1 or larger the new Color is equivalent to target.

Parameters:
Name Type Description
ratio number

The transition ratio for the new Color

target Rac.Color

The transition target Color

stroke(weightnullable) → {Rac.Stroke}

Returns a new Stroke that uses this as color.

Parameters:
Name Type Attributes Default Description
weight number <nullable>
null

The weight of the new Stroke

toString() → {string}

# | source: style/Color.js, line 67

Returns a string representation intended for human consumption.

withAlpha(newAlpha) → {Rac.Color}

Returns a new Color with a set to newAlpha.

Parameters:
Name Type Description
newAlpha number

The alpha channel for the new Color, in the [0,1] range

withAlphaRatio(ratio) → {Rac.Color}

Returns a new Color with a set to this.a * ratio.

Parameters:
Name Type Description
ratio number

The factor to multiply a by