Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Color4

Class used to hold a RBGA color

Hierarchy

  • Color4

Index

Constructors

constructor

  • new Color4(r?: number, g?: number, b?: number, a?: number): Color4
  • Creates a new Color4 object from red, green, blue values, all between 0 and 1

    Parameters

    • Default value r: number = 0

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

    • Default value g: number = 0

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

    • Default value b: number = 0

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

    • Default value a: number = 1

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

    Returns Color4

Properties

a

a: number

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

b

b: number

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

g

g: number

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

r

r: number

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

Methods

add

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

    Parameters

    • right: Color4

      defines the second operand

    Returns Color4

    a new Color4 object

addInPlace

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

    Parameters

    • right: Color4

      defines the second operand

    Returns Color4

    the current updated Color4 object

asArray

  • asArray(): number[]
  • Creates a new array populated with 4 numeric elements : red, green, blue, alpha values

    Returns number[]

    the new array

clampToRef

  • clampToRef(min?: number, max?: number, result: Color4): Color4
  • Clamps the rgb values by the min and max values and stores the result into "result"

    Parameters

    • Default value min: number = 0

      defines minimum clamping value (default is 0)

    • Default value max: number = 1

      defines maximum clamping value (default is 1)

    • result: Color4

      defines color to store the result into.

    Returns Color4

    the cuurent Color4

clone

copy

  • Updates the Color4 from the sparsely populated value.

    Parameters

    • from: Partial<Color4Like>

      The sparsely populated value to read from.

    Returns this

copyFrom

  • Copies the given Color4 values into the current one

    Parameters

    • source: Color4

      defines the source Color4 object

    Returns Color4

    the current updated Color4 object

copyFromFloats

  • copyFromFloats(r: number, g: number, b: number, a: number): Color4
  • Copies the given float values into the current one

    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

    the current updated Color4 object

getClassName

  • getClassName(): string

getHashCode

  • getHashCode(): number
  • Compute the Color4 hash code

    Returns number

    an unique number that can be used to hash Color4 objects

multiply

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

    Parameters

    • color: Color4

      defines the Color4 value to multiply by

    Returns Color4

    a new Color4 object

multiplyToRef

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

    Parameters

    • color: Color4

      defines the Color4 value to multiply by

    • result: Color4

      defines the Color4 to fill the result in

    Returns Color4

    the result Color4

scale

  • scale(scale: number): Color4
  • Creates a new Color4 with the current Color4 values multiplied by scale

    Parameters

    • scale: number

      defines the scaling factor to apply

    Returns Color4

    a new Color4 object

scaleAndAddToRef

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

    Parameters

    • scale: number

      defines the scale factor

    • result: Color4

      defines the Color4 object where to store the result

    Returns Color4

    the unmodified current Color4

scaleToRef

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

    Parameters

    • scale: number

      defines the scaling factor to apply

    • result: Color4

      defines the Color4 object where to store the result

    Returns Color4

    the current unmodified Color4

set

  • set(r: number, g: number, b: number, a: number): Color4
  • Copies the given float values into the current one

    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

    the current updated Color4 object

subtract

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

    Parameters

    • right: Color4

      defines the second operand

    Returns Color4

    a new Color4 object

subtractToRef

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

    Parameters

    • right: Color4

      defines the second operand

    • result: Color4

      defines the Color4 object where to store the result

    Returns Color4

    the current Color4 object

toArray

  • toArray(array: number[], index?: number): Color4
  • Stores from the starting index in the given array the Color4 successive values

    Parameters

    • array: number[]

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

    • Default value index: number = 0

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

    Returns Color4

    the current Color4 object

toGammaSpace

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

    Returns Color4

    a new Color4 object

toGammaSpaceToRef

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

    Parameters

    • convertedColor: Color4

      defines the Color4 object where to store the gamma space version

    Returns Color4

    the unmodified Color4

toHexString

  • toHexString(): string
  • Compute the Color4 hexadecimal code as a string

    Returns string

    a string containing the hexadecimal representation of the Color4 object

toJSON

  • Returns a JSON representation of this color. This is necessary due to the way Actors detect changes on components like the actor's transform. They do this by adding properties for observation, and we don't want these properties serialized.

    Returns Color4Like

toLinearSpace

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

    Returns Color4

    a new Color4 object

toLinearSpaceToRef

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

    Parameters

    • convertedColor: Color4

      defines the Color4 object where to store the linear space version

    Returns Color4

    the unmodified Color4

toString

  • toString(): string
  • Creates a string with the Color4 current values

    Returns string

    the string representation of the Color4 object

Static CheckColors4

  • CheckColors4(colors: number[], count: number): number[]
  • 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

    Parameters

    • colors: number[]

      defines the array to check

    • count: number

      defines the number of RGBA data to expect

    Returns number[]

    an array containing count * 4 values (RGBA)

Static FromArray

  • FromArray(array: ArrayLike<number>, offset?: number): Color4
  • Creates a new Color4 from the starting index element of the given array

    Parameters

    • array: ArrayLike<number>

      defines the source array to read from

    • Default value offset: number = 0

      defines the offset in the source array

    Returns Color4

    a new Color4 object

Static FromColor3

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

    Parameters

    • color3: Color3

      defines the source Color3 to read from

    • Default value alpha: number = 1

      defines the alpha component (1.0 by default)

    Returns Color4

    a new Color4 object

Static FromHexString

  • FromHexString(hex: string): Color4
  • Creates a new Color4 from the string containing valid hexadecimal values

    Parameters

    • hex: string

      defines a string containing valid hexadecimal values

    Returns Color4

    a new Color4 object

Static FromInts

  • FromInts(r: number, g: number, b: number, a: number): Color4
  • Creates a new Color3 from integer values (< 256)

    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

    a new Color3 object

Static Lerp

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

    Parameters

    • left: Color4

      defines the start value

    • right: Color4

      defines the end value

    • amount: number

      defines the gradient factor

    Returns Color4

    a new Color4 object

Static LerpToRef

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

    Parameters

    • left: Color4

      defines the start value

    • right: Color4

      defines the end value

    • amount: number

      defines the gradient factor

    • result: Color4

      defines the Color4 object where to store data

    Returns void