Class used to hold a RBGA color

Hierarchy

  • Color4

Constructors

  • Creates a new Color4 object from red, green, blue values, all between 0 and 1

    Parameters

    • Optional r: number

      defines the red component (between 0 and 1, default is 0)

    • Optional g: number

      defines the green component (between 0 and 1, default is 0)

    • Optional b: number

      defines the blue component (between 0 and 1, default is 0)

    • Optional a: number

      defines the alpha component (between 0 and 1, default is 1)

    Returns Color4

Properties

a: number

Defines the alpha component (between 0 and 1, default is 1)

b: number

Defines the blue component (between 0 and 1, default is 0)

g: number

Defines the green component (between 0 and 1, default is 0)

r: number

Defines the red component (between 0 and 1, default is 0)

Methods

  • Creates a new Color4 set with the added values of the current Color4 and of the given one

    Returns

    a new Color4 object

    Parameters

    • right: DeepImmutableObject<Color4>

      defines the second operand

    Returns Color4

  • Adds in place the given Color4 values to the current Color4 object

    Returns

    the current updated Color4 object

    Parameters

    • right: DeepImmutableObject<Color4>

      defines the second operand

    Returns Color4

  • Creates a new array populated with 4 numeric elements : red, green, blue, alpha values

    Returns

    the new array

    Returns number[]

  • Clamps the rgb values by the min and max values and stores the result into "result"

    Returns

    the current Color4

    Parameters

    • min: undefined | number

      defines minimum clamping value (default is 0)

    • max: undefined | number

      defines maximum clamping value (default is 1)

    • result: Color4

      defines color to store the result into.

    Returns Color4

  • Creates a new Color4 copied from the current one

    Returns

    a new Color4 object

    Returns Color4

  • Copies the given Color4 values into the current one

    Returns

    the current updated Color4 object

    Parameters

    • source: Color4

      defines the source Color4 object

    Returns Color4

  • Copies the given float values into the current one

    Returns

    the current updated Color4 object

    Parameters

    • r: number

      defines the red component to read from

    • g: number

      defines the green component to read from

    • b: number

      defines the blue component to read from

    • a: number

      defines the alpha component to read from

    Returns Color4

  • Determines equality between Color4 objects

    Returns

    true if the rgba values are equal to the given ones

    Parameters

    • otherColor: DeepImmutableObject<Color4>

      defines the second operand

    Returns boolean

  • Update the current color with values stored in an array from the starting index of the given array

    Returns

    the current Color4 object

    Parameters

    • array: DeepImmutableObject<ArrayLike<number>>

      defines the source array

    • Optional offset: number

      defines an offset in the source array

    Returns Color4

  • Returns the string "Color4"

    Returns

    "Color4"

    Returns string

  • Compute the Color4 hash code

    Returns

    an unique number that can be used to hash Color4 objects

    Returns number

  • Multiply an Color4 value by another and return a new Color4 object

    Returns

    a new Color4 object

    Parameters

    • color: Color4

      defines the Color4 value to multiply by

    Returns Color4

  • Multiply a Color4 value by another and push the result in a reference value

    Returns

    the result Color4

    Parameters

    • color: Color4

      defines the Color4 value to multiply by

    • result: Color4

      defines the Color4 to fill the result in

    Returns Color4

  • Creates a new Color4 with the current Color4 values multiplied by scale

    Returns

    a new Color4 object

    Parameters

    • scale: number

      defines the scaling factor to apply

    Returns Color4

  • Scale the current Color4 values by a factor and add the result to a given Color4

    Returns

    the unmodified current Color4

    Parameters

    • scale: number

      defines the scale factor

    • result: Color4

      defines the Color4 object where to store the result

    Returns Color4

  • Multiplies the Color4 values by the float "scale"

    Returns

    the current updated Color4

    Parameters

    • scale: number

      defines the scaling factor to apply

    Returns Color4

  • Multiplies the current Color4 values by scale and stores the result in "result"

    Returns

    the current unmodified Color4

    Parameters

    • scale: number

      defines the scaling factor to apply

    • result: Color4

      defines the Color4 object where to store the result

    Returns Color4

  • Copies the given float values into the current one

    Returns

    the current updated Color4 object

    Parameters

    • r: number

      defines the red component to read from

    • g: number

      defines the green component to read from

    • b: number

      defines the blue component to read from

    • a: number

      defines the alpha component to read from

    Returns Color4

  • Creates a new Color4 set with the subtracted values of the given one from the current Color4

    Returns

    a new Color4 object

    Parameters

    • right: DeepImmutableObject<Color4>

      defines the second operand

    Returns Color4

  • Subtracts the given ones from the current Color4 values and stores the results in "result"

    Returns

    the current Color4 object

    Parameters

    • right: DeepImmutableObject<Color4>

      defines the second operand

    • result: Color4

      defines the Color4 object where to store the result

    Returns Color4

  • Stores from the starting index in the given array the Color4 successive values

    Returns

    the current Color4 object

    Parameters

    • array: FloatArray

      defines the array where to store the r,g,b components

    • Optional index: number

      defines an optional index in the target array to define where to start storing values

    Returns Color4

  • Computes a new Color4 converted from the current one to gamma space

    Returns

    a new Color4 object

    Parameters

    • Optional exact: boolean

      defines if the conversion will be done in an exact way which is slower but more accurate (default is false)

    Returns Color4

  • Converts the Color4 values to gamma space and stores the result in "convertedColor"

    Returns

    the unmodified Color4

    Parameters

    • convertedColor: Color4

      defines the Color4 object where to store the gamma space version

    • Optional exact: boolean

      defines if the conversion will be done in an exact way which is slower but more accurate (default is false)

    Returns Color4

  • Compute the Color4 hexadecimal code as a string

    Returns

    a string containing the hexadecimal representation of the Color4 object

    Parameters

    • Optional returnAsColor3: boolean

      defines if the string should only contains RGB values (off by default)

    Returns string

  • Computes a new Color4 converted from the current one to linear space

    Returns

    a new Color4 object

    Parameters

    • Optional exact: boolean

      defines if the conversion will be done in an exact way which is slower but more accurate (default is false)

    Returns Color4

  • Converts the Color4 values to linear space and stores the result in "convertedColor"

    Returns

    the unmodified Color4

    Parameters

    • convertedColor: Color4

      defines the Color4 object where to store the linear space version

    • Optional exact: boolean

      defines if the conversion will be done in an exact way which is slower but more accurate (default is false)

    Returns Color4

  • Creates a string with the Color4 current values

    Returns

    the string representation of the Color4 object

    Returns string

  • Check the content of a given array and convert it to an array containing RGBA data If the original array was already containing count * 4 values then it is returned directly

    Returns

    an array containing count * 4 values (RGBA)

    Parameters

    • colors: number[]

      defines the array to check

    • count: number

      defines the number of RGBA data to expect

    Returns number[]

  • Creates a new Color4 from the starting index element of the given array

    Returns

    a new Color4 object

    Parameters

    • array: DeepImmutableObject<ArrayLike<number>>

      defines the source array to read from

    • Optional offset: number

      defines the offset in the source array

    Returns Color4

  • Creates a new Color4 from the starting index element of the given array

    Parameters

    • array: DeepImmutableObject<ArrayLike<number>>

      defines the source array to read from

    • offset: undefined | number

      defines the offset in the source array

    • result: Color4

      defines the target Color4 object

    Returns void

  • Creates a new Color4 from a Color3 and an alpha value

    Returns

    a new Color4 object

    Parameters

    • color3: DeepImmutableObject<Color3>

      defines the source Color3 to read from

    • Optional alpha: number

      defines the alpha component (1.0 by default)

    Returns Color4

  • Creates a new Color4 from the string containing valid hexadecimal values.

    A valid hex string is either in the format #RRGGBB or #RRGGBBAA.

    When a hex string without alpha is passed, the resulting Color4 has its alpha value set to 1.0.

    An invalid string results in a Color with all its channels set to 0.0, i.e. "transparent black".

    Returns

    a new Color4 object

    Parameters

    • hex: string

      defines a string containing valid hexadecimal values

    Returns Color4

  • Creates a new Color3 from integer values (< 256)

    Returns

    a new Color3 object

    Parameters

    • r: number

      defines the red component to read from (value between 0 and 255)

    • g: number

      defines the green component to read from (value between 0 and 255)

    • b: number

      defines the blue component to read from (value between 0 and 255)

    • a: number

      defines the alpha component to read from (value between 0 and 255)

    Returns Color4

  • Interpolate between two Color4 using Hermite interpolation

    Returns

    the new interpolated Color4

    Parameters

    • value1: DeepImmutableObject<Color4>

      defines first Color4

    • tangent1: DeepImmutableObject<Color4>

      defines the incoming tangent

    • value2: DeepImmutableObject<Color4>

      defines second Color4

    • tangent2: DeepImmutableObject<Color4>

      defines the outgoing tangent

    • amount: number

      defines the target Color4

    Returns Color4

  • Returns a new Color4 which is the 1st derivative of the Hermite spline defined by the colors "value1", "value2", "tangent1", "tangent2".

    Returns

    1st derivative

    Parameters

    • value1: DeepImmutableObject<Color4>

      defines the first control point

    • tangent1: DeepImmutableObject<Color4>

      defines the first tangent

    • value2: DeepImmutableObject<Color4>

      defines the second control point

    • tangent2: DeepImmutableObject<Color4>

      defines the second tangent

    • time: number

      define where the derivative must be done

    Returns Color4

  • Update a Color4 with the 1st derivative of the Hermite spline defined by the colors "value1", "value2", "tangent1", "tangent2".

    Parameters

    • value1: DeepImmutableObject<Color4>

      defines the first control point

    • tangent1: DeepImmutableObject<Color4>

      defines the first tangent

    • value2: DeepImmutableObject<Color4>

      defines the second control point

    • tangent2: DeepImmutableObject<Color4>

      defines the second tangent

    • time: number

      define where the derivative must be done

    • result: Color4

      define where to store the derivative

    Returns void

  • Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object

    Returns

    a new Color4 object

    Parameters

    • left: DeepImmutableObject<Color4>

      defines the start value

    • right: DeepImmutableObject<Color4>

      defines the end value

    • amount: number

      defines the gradient factor

    Returns Color4

  • Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object

    Parameters

    • left: DeepImmutableObject<Color4>

      defines the start value

    • right: DeepImmutableObject<Color4>

      defines the end value

    • amount: number

      defines the gradient factor

    • result: Color4

      defines the Color4 object where to store data

    Returns void

Generated using TypeDoc