Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Color3

Class used to hold a RBG color

Hierarchy

  • Color3

Implements

Index

Constructors

constructor

  • new Color3(r?: number, g?: number, b?: number): Color3
  • Creates a new Color3 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)

    Returns Color3

Properties

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 Color3 set with the added values of the current Color3 and of the given one

    Parameters

    • otherColor: Color3

      defines the second operand

    Returns Color3

    the new Color3

addToRef

  • Stores the result of the addition of the current Color3 and given one rgb values into "result"

    Parameters

    • otherColor: Color3

      defines the second operand

    • result: Color3

      defines Color3 object to store the result into

    Returns Color3

    the unmodified current Color3

asArray

  • asArray(): number[]
  • Returns a new array populated with 3 numeric elements : red, green and blue values

    Returns number[]

    the new array

clampToRef

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

    Parameters

    • min: number

      defines minimum clamping value (default is 0)

    • max: number

      defines maximum clamping value (default is 1)

    • result: Color3

      defines color to store the result into

    Returns Color3

    the original Color3

clone

  • Copy the current object

    Returns Color3

    a new Color3 copied the current one

copy

  • Updates the Color3 from the sparsely populated value.

    Parameters

    • from: Partial<Color3Like>

      The sparsely populated value to read from.

    Returns this

copyFrom

  • Copies the rgb values from the source in the current Color3

    Parameters

    • source: Color3

      defines the source Color3 object

    Returns Color3

    the updated Color3 object

copyFromArray

  • copyFromArray(arr: FloatArray, index?: number): this
  • Parameters

    • arr: FloatArray
    • Optional index: number

    Returns this

copyFromFloats

  • copyFromFloats(r: number, g: number, b: number): Color3
  • Updates the Color3 rgb values from the given floats

    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

    Returns Color3

    the current Color3 object

equals

  • equals(otherColor: Partial<Color3>): boolean
  • Determines equality between Color3 objects

    Parameters

    • otherColor: Partial<Color3>

      defines the second operand

    Returns boolean

    true if the rgb values are equal to the given ones

equalsFloats

  • equalsFloats(r: number, g: number, b: number): boolean
  • Determines equality between the current Color3 object and a set of r,b,g values

    Parameters

    • r: number

      defines the red component to check

    • g: number

      defines the green component to check

    • b: number

      defines the blue component to check

    Returns boolean

    true if the rgb values are equal to the given ones

getClassName

  • getClassName(): string
  • Returns the string "Color3"

    Returns string

    "Color3"

getHashCode

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

    Returns number

    an unique number that can be used to hash Color3 objects

multiply

  • Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object

    Parameters

    • otherColor: Color3

      defines the second operand

    Returns Color3

    the new Color3 object

multiplyToRef

  • Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"

    Parameters

    • otherColor: Color3

      defines the second operand

    • result: Color3

      defines the Color3 object where to store the result

    Returns Color3

    the current Color3

scale

  • scale(scale: number): Color3
  • Multiplies in place each rgb value by scale

    Parameters

    • scale: number

      defines the scaling factor

    Returns Color3

    the updated Color3

scaleAndAddToRef

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

    Parameters

    • scale: number

      defines the scale factor

    • result: Color3

      defines color to store the result into

    Returns Color3

    the unmodified current Color3

scaleToRef

  • Multiplies the rgb values by scale and stores the result into "result"

    Parameters

    • scale: number

      defines the scaling factor

    • result: Color3

      defines the Color3 object where to store the result

    Returns Color3

    the unmodified current Color3

set

  • set(r: number, g: number, b: number): Color3
  • Updates the Color3 rgb values from the given floats

    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

    Returns Color3

    the current Color3 object

subtract

  • Returns a new Color3 set with the subtracted values of the given one from the current Color3

    Parameters

    • otherColor: Color3

      defines the second operand

    Returns Color3

    the new Color3

subtractToRef

  • Stores the result of the subtraction of given one from the current Color3 rgb values into "result"

    Parameters

    • otherColor: Color3

      defines the second operand

    • result: Color3

      defines Color3 object to store the result into

    Returns Color3

    the unmodified current Color3

toArray

  • toArray(array: FloatArray, index?: number): Color3
  • Stores in the given array from the given starting index the red, green, blue values as successive elements

    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 Color3

    the current Color3 object

toColor4

  • toColor4(alpha?: number): Color4
  • Returns a new Color4 object from the current Color3 and the given alpha

    Parameters

    • Optional alpha: number

      defines the alpha component on the new Color4 object (default is 1)

    Returns Color4

    a new Color4 object

toGammaSpace

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

    Returns Color3

    a new Color3 object

toGammaSpaceToRef

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

    Parameters

    • convertedColor: Color3

      defines the Color3 object where to store the gamma space version

    Returns Color3

    the unmodified Color3

toHexString

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

    Returns string

    a string containing the hexadecimal representation of the Color3 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 Color3Like

toLinearSpace

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

    Returns Color3

    a new Color3 object

toLinearSpaceToRef

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

    Parameters

    • convertedColor: Color3

      defines the Color3 object where to store the linear space version

    Returns Color3

    the unmodified Color3

toLuminance

  • toLuminance(): number
  • Returns the luminance value

    Returns number

    a float value

toString

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

    Returns string

    the string representation of the Color3 object

Static Black

  • Returns a Color3 value containing a black color

    Returns Color3

    a new Color3 object

Static Blue

  • Returns a Color3 value containing a blue color

    Returns Color3

    a new Color3 object

Static DarkGray

  • Returns a Color3 value containing a dark gray color

    Returns Color3

    a new Color3 object

Static FromArray

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

    Parameters

    • array: ArrayLike<number>

      defines the source array

    • Optional offset: number

      defines an offset in the source array

    Returns Color3

    a new Color3 object

Static FromHexString

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

    Parameters

    • hex: string

      defines a string containing valid hexadecimal values

    Returns Color3

    a new Color3 object

Static FromInts

  • FromInts(r: number, g: number, b: number): Color3
  • 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)

    Returns Color3

    a new Color3 object

Static Gray

  • Returns a Color3 value containing a gray color

    Returns Color3

    a new Color3 object

Static Green

  • Returns a Color3 value containing a green color

    Returns Color3

    a new Color3 object

Static Lerp

  • Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3

    Parameters

    • start: Color3

      defines the start Color3 value

    • end: Color3

      defines the end Color3 value

    • amount: number

      defines the gradient value between start and end

    Returns Color3

    a new Color3 object

Static LerpToRef

  • Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3

    Parameters

    • left: Color3

      defines the start value

    • right: Color3

      defines the end value

    • amount: number

      defines the gradient factor

    • result: Color3

      defines the Color3 object where to store the result

    Returns void

Static LightGray

  • Returns a Color3 value containing a light gray color

    Returns Color3

    a new Color3 object

Static Magenta

  • Returns a Color3 value containing a magenta color

    Returns Color3

    a new Color3 object

Static Purple

  • Returns a Color3 value containing a purple color

    Returns Color3

    a new Color3 object

Static Random

  • Returns a Color3 value containing a random color

    Returns Color3

    a new Color3 object

Static Red

  • Returns a Color3 value containing a red color

    Returns Color3

    a new Color3 object

Static Teal

  • Returns a Color3 value containing a teal color

    Returns Color3

    a new Color3 object

Static White

  • Returns a Color3 value containing a white color

    Returns Color3

    a new Color3 object

Static Yellow

  • Returns a Color3 value containing a yellow color

    Returns Color3

    a new Color3 object