Class ColorRGBA

Color with 4 floating point components: red, green, blue and alpha (r, g, b, a). \ingroup Math

ColorRGBA constructors

Functions which can be used to create new instances of ColorRGBA.

Synopsis

Methods
ColorRGBA()

Default constructor, initializes the color to (0.0, 0.0, 0.0, 0.0)

ColorRGBA()

Constructor, initializes the color to (v, v, v, v)

ColorRGBA()

Constructor, initializes the color to (r, g, b, 1.0)

ColorRGBA()

Constructor, initializes the color to (r, g, b, a)

ColorRGBA()

Default constructor, initializes the color to (0.0, 0.0, 0.0, 0.0).

Example
local colorrgba = ColorRGBA()
ColorRGBA(v)

Constructor, initializes the color to (v, v, v, v).

Example
local colorrgba = ColorRGBA(v)
Parameters
v (float)

Red, Green, Blue, and Alpha component of the color.

ColorRGBA(r, g, b)

Constructor, initializes the color to (r, g, b, 1.0).

Example
local colorrgba = ColorRGBA(r, g, b)
Parameters
r (float)

Red component of the color.

g (float)

Green component of the color.

b (float)

Blue component of the color.

ColorRGBA(r, g, b, a)

Constructor, initializes the color to (r, g, b, a).

Example
local colorrgba = ColorRGBA(r, g, b, a)
Parameters
r (float)

Red component of the color.

g (float)

Green component of the color.

b (float)

Blue component of the color.

a (float)

Alpha component of the color.

ColorRGBA methods

Methods of ColorRGBA class.

Synopsis

Methods
ColorRGBA.zero()

Returns the color with each element being zero

ColorRGBA.one()

Returns the color with each element being one

ColorRGBA.fromSRGB()

Returns a linear color with each element set from a sRGB value

ColorRGBA.fromSRGB()

Returns a linear color with each element set from a sRGB value

ColorRGBA:getRed()

Returns the red element of the color

ColorRGBA:getGreen()

Returns the green element of the color

ColorRGBA:getBlue()

Returns the blue element of the color

ColorRGBA:getAlpha()

Returns the alpha element of the color

ColorRGBA:setRed()

Sets the red element of the color

ColorRGBA:setGreen()

Sets the green element of the color

ColorRGBA:setBlue()

Sets the blue element of the color

ColorRGBA:setAlpha()

Sets the alpha element of the color

ColorRGBA:hasNan()

Returns true if and only if at least one of the vector values is NaN

ColorRGBA.lowestValue()

Returns the color with each element having the most negative float value

ColorRGBA.highestValue()

Returns the color with each element having the most positive float value

ColorRGBA.nan()

Returns the color with each element being NaN

ColorRGBA.positiveInfinity()

Returns the color with each element being the positive infinity

ColorRGBA.negativeInfinity()

Returns the color with each element being the negative infinity

ColorRGBA.opaqueBlack()

Returns opaque black color (0.0, 0.0, 0.0, 1.0)

ColorRGBA.transparentBlack()

Returns transparent black color (0.0, 0.0, 0.0, 0.0)

ColorRGBA.zero()

Returns the color with each element being zero.

Return Values
(ColorRGBA)

Color with zeroed elements.

ColorRGBA.one()

Returns the color with each element being one.

Return Values
(ColorRGBA)

Color with unit element values.

ColorRGBA.fromSRGB(r, g, b, a)

Returns a linear color with each element set from a sRGB value.

Parameters
r (float)

Red Channel (0-1.0)

g (float)

Green Channel (0-1.0)

b (float)

Blue Channel (0-1.0)

a (float)

Alpha Channel (0-1.0)

Return Values
(ColorRGBA)

Color in linear color space.

ColorRGBA.fromSRGB(r, g, b)

Returns a linear color with each element set from a sRGB value.

Parameters
r (float)

Red Channel (0-1.0)

g (float)

Green Channel (0-1.0)

b (float)

Blue Channel (0-1.0)

Return Values
(ColorRGBA)

Color in linear color space.

ColorRGBA:getRed()

Returns the red element of the color

Return Values
(float)

The red element.

ColorRGBA:getGreen()

Returns the green element of the color

Return Values
(float)

The green element.

ColorRGBA:getBlue()

Returns the blue element of the color

Return Values
(float)

The blue element.

ColorRGBA:getAlpha()

Returns the alpha element of the color

Return Values
(float)

The alpha element.

ColorRGBA:setRed(value)

Sets the red element of the color.

Parameters
value (float)

The new value of the red element.

ColorRGBA:setGreen(value)

Sets the green element of the color.

Parameters
value (float)

The new value of the green element.

ColorRGBA:setBlue(value)

Sets the blue element of the color.

Parameters
value (float)

The new value of the blue element.

ColorRGBA:setAlpha(value)

Sets the alpha element of the color.

Parameters
value (float)

The new value of the alpha element.

ColorRGBA:hasNan()

Returns true if and only if at least one of the vector values is NaN.

ColorRGBA.lowestValue()

Returns the color with each element having the most negative float value.

Return Values
(ColorRGBA)

Color with the lowest possible value.

ColorRGBA.highestValue()

Returns the color with each element having the most positive float value.

Return Values
(ColorRGBA)

Color with the highest possible value.

ColorRGBA.nan()

Returns the color with each element being NaN.

Return Values
(ColorRGBA)

Color with NaN elements.

ColorRGBA.positiveInfinity()

Returns the color with each element being the positive infinity.

Return Values
(ColorRGBA)

Color with positive infinity elements.

ColorRGBA.negativeInfinity()

Returns the color with each element being the negative infinity.

Return Values
(ColorRGBA)

Color with negative infinity elements.

ColorRGBA.opaqueBlack()

Returns opaque black color (0.0, 0.0, 0.0, 1.0).

Return Values
(ColorRGBA)

Opaque black.

ColorRGBA.transparentBlack()

Returns transparent black color (0.0, 0.0, 0.0, 0.0).

Return Values
(ColorRGBA)

Transparent black color.

ColorRGBA functions

ColorRGBA specific standalone functions, which are not a part of the ColorRGBA class.

Synopsis

Functions
componentAbs()

Calculates component-wise absolute value for all elements and returns the resulting color

componentCeil()

Calculates component-wise ceil value for all elements and returns the resulting color

componentFloor()

Calculates component-wise floor value for all elements and returns the resulting color

componentRound()

Calculates component-wise rounded value for all elements and returns the resulting color

componentSqrt()

Calculates component-wise square root all elements and returns the resulting color

componentWiseMax()

Calculates component-wise maximum for all color elements and returns the resulting color

componentWiseMin()

Calculates component-wise minimum for all color elements and returns the resulting color

componentWiseMultiply()

Multiplies component-wise all color elements and returns the resulting color

componentWiseDivide()

Divides component-wise all color elements and returns the resulting color

componentWiseRemainder()

Calculates component-wise the remainder for all color elements and returns the resulting color

componentAdd()

Adds a value to all color elements and returns the resulting color

componentSubtract()

Subtracts a value from all color elements and returns the resulting color

dotProduct()

Calculates the dot product of two colors

sRGBToLinear()

Converts to whole ColorRGBA from sRGB to linear

linearTosRGB()

Converts whole ColorRGBA color from linear to sRGB

componentAbs(v)

Calculates component-wise absolute value for all elements and returns the resulting color.

Parameters
v (ColorRGBA)

Color input.

Return Values
(ColorRGBA)

The result color.

componentCeil(v)

Calculates component-wise ceil value for all elements and returns the resulting color.

Parameters
v (ColorRGBA)

Color input.

Return Values
(ColorRGBA)

The result color.

componentFloor(v)

Calculates component-wise floor value for all elements and returns the resulting color.

Parameters
v (ColorRGBA)

Color input.

Return Values
(ColorRGBA)

The result color.

componentRound(v)

Calculates component-wise rounded value for all elements and returns the resulting color.

Parameters
v (ColorRGBA)

Color input.

Return Values
(ColorRGBA)

The result color.

componentSqrt(v)

Calculates component-wise square root all elements and returns the resulting color.

Parameters
v (ColorRGBA)

Color input.

Return Values
(ColorRGBA)

The result color.

componentWiseMax(v1, v2)

Calculates component-wise maximum for all color elements and returns the resulting color.

Parameters
v1 (ColorRGBA)

The first color.

v2 (ColorRGBA)

The second color.

Return Values
(ColorRGBA)

The result color.

componentWiseMin(v1, v2)

Calculates component-wise minimum for all color elements and returns the resulting color.

Parameters
v1 (ColorRGBA)

The first color.

v2 (ColorRGBA)

The second color.

Return Values
(ColorRGBA)

The result color.

componentWiseMultiply(v1, v2)

Multiplies component-wise all color elements and returns the resulting color.

Parameters
v1 (ColorRGBA)

The first color.

v2 (ColorRGBA)

The second color.

Return Values
(ColorRGBA)

The result color.

componentWiseDivide(v1, v2)

Divides component-wise all color elements and returns the resulting color.

Parameters
v1 (ColorRGBA)

The first color.

v2 (ColorRGBA)

The second color.

Return Values
(ColorRGBA)

The result color.

componentWiseRemainder(v1, v2)

Calculates component-wise the remainder for all color elements and returns the resulting color.

Parameters
v1 (ColorRGBA)

The first color.

v2 (ColorRGBA)

The second color.

Return Values
(ColorRGBA)

The result color.

componentAdd(v, scalar)

Adds a value to all color elements and returns the resulting color.

Parameters
v (ColorRGBA)

Color.

scalar (float)

Value

Return Values
(ColorRGBA)

Result color.

componentSubtract(v, scalar)

Subtracts a value from all color elements and returns the resulting color.

Parameters
v (ColorRGBA)

Color.

scalar (float)

Value

Return Values
(ColorRGBA)

Result color.

dotProduct(v1, v2)

Calculates the dot product of two colors.

Parameters
v1 (ColorRGBA)

The first color.

v2 (ColorRGBA)

The second color.

Return Values
(float)

The dot product of the colors.

sRGBToLinear(cs)

Converts to whole ColorRGBA from sRGB to linear.

Parameters
cs (ColorRGBA)

Color in sRGB format.

Return Values
(ColorRGBA)

Color in linear format.

linearTosRGB(cs)

Converts whole ColorRGBA color from linear to sRGB.

Parameters
cs (ColorRGBA)

Color in linear format.

Return Values
(ColorRGBA)

Color in sRGB format.