API

Class Color3

Class used to hold a RGB color

Implements

  • Tensor<Tuple<number, 3>, IColor3Like>
Index
  • Creates a new Color3 object from red, green, blue values, all between 0 and 1

    Parameters

    • r: number = 0

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

    • g: number = 0

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

    • b: number = 0

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

    Returns Color3

b: number = 0

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

dimension: [3]

Tensor.dimension

g: number = 0

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

r: number = 0

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

rank: 1

Tensor.rank

_V8PerformanceHack: DeepImmutableObject<Color3> = ...

If the first color is flagged with integers (as everything is 0,0,0), V8 stores all of the properties as integers internally because it doesn't know any better yet. If subsequent colors are created with non-integer values, V8 determines that it would be best to represent these properties as doubles instead of integers, and henceforth it will use floating-point representation for all color instances that it creates. But the original color instances are unchanged and has a "deprecated map". If we keep using the color instances from step 1, it will now be a poison pill which will mess up optimizations in any code it touches.

  • Adds the given coordinates to the current Color3

    Parameters

    • r: number

      defines the r coordinate of the operand

    • g: number

      defines the g coordinate of the operand

    • b: number

      defines the b coordinate of the operand

    Returns this

    the current updated Color3

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

    Type Parameters

    • T extends IColor3Like

    Parameters

    • otherColor: DeepImmutable<IColor3Like>

      defines the second operand

    • result: T

      defines Color3 object to store the result into

    Returns T

    the unmodified current Color3

  • Returns a new array populated with 3 numeric elements : red, green and blue values

    Returns [number, number, number]

    the new array

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

    Type Parameters

    • T extends IColor3Like

    Parameters

    • min: number = 0

      defines minimum clamping value (default is 0)

    • max: number = 1

      defines maximum clamping value (default is 1)

    • result: T

      defines color to store the result into

    Returns T

    the result 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 this

    the current Color3 object

  • Alias for equalsToFloats

    Parameters

    • r: number

      red color component

    • g: number

      green color component

    • b: number

      blue color component

    Returns boolean

    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

  • Returns true if the current Color3 and the given color coordinates are distant less than epsilon

    Parameters

    • otherColor: DeepImmutable<IColor3Like>

      defines the second operand

    • epsilon: number = Epsilon

      defines the minimal distance to define values as equals

    Returns boolean

    true if both colors are distant less than epsilon

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

    Parameters

    • array: DeepImmutable<ArrayLike<number>>

      defines the source array

    • offset: number = 0

      defines an offset in the source array

    Returns this

    the current Color3 object

  • Updates the Color3 rgb values from the string containing valid hexadecimal values

    Parameters

    • hex: string

      defines a string containing valid hexadecimal values

    Returns this

    the current Color3 object

  • Updates the current Color3 with the maximal coordinate values between its and the given coordinates.

    Parameters

    • r: number

      defines the r coordinate of the operand

    • g: number

      defines the g coordinate of the operand

    • b: number

      defines the b coordinate of the operand

    Returns this

    the current updated Color3

  • Updates the current Color3 with the minimal coordinate values between its and the given coordinates

    Parameters

    • r: number

      defines the r coordinate of the operand

    • g: number

      defines the g coordinate of the operand

    • b: number

      defines the b coordinate of the operand

    Returns this

    the current updated Color3

  • Returns a new Color3 set with the result of the multiplication of the current Color3 coordinates by the given floats

    Parameters

    • r: number

      defines the r coordinate of the operand

    • g: number

      defines the g coordinate of the operand

    • b: number

      defines the b coordinate of the operand

    Returns Color3

    the new Color3

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

    Type Parameters

    • T extends IColor3Like

    Parameters

    • otherColor: DeepImmutable<IColor3Like>

      defines the second operand

    • result: T

      defines the Color3 object where to store the result

    Returns T

    the result Color3

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

    Type Parameters

    • T extends IColor3Like

    Parameters

    • scale: number

      defines the scale factor

    • result: T

      defines color to store the result into

    Returns T

    the result Color3

  • Multiplies the Color3 values by the float "scale"

    Parameters

    • scale: number

      defines the scaling factor to apply

    Returns this

    the current updated Color3

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

    Type Parameters

    • T extends IColor3Like

    Parameters

    • scale: number

      defines the scaling factor

    • result: T

      defines the Color3 object where to store the result

    Returns T

    the result 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 this

    the current Color3 object

  • Copies the given float to the current Color3 coordinates

    Parameters

    • v: number

      defines the r, g and b coordinates of the operand

    Returns this

    the current updated Color3

  • Returns a new Color3 set with the subtraction of the given floats from the current Color3 coordinates

    Parameters

    • r: number

      defines the r coordinate of the operand

    • g: number

      defines the g coordinate of the operand

    • b: number

      defines the b coordinate of the operand

    Returns Color3

    the resulting Color3

  • Subtracts the given floats from the current Color3 coordinates and set the given color "result" with this result

    Type Parameters

    • T extends IColor3Like

    Parameters

    • r: number

      defines the r coordinate of the operand

    • g: number

      defines the g coordinate of the operand

    • b: number

      defines the b coordinate of the operand

    • result: T

      defines the Color3 object where to store the result

    Returns T

    the result

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

    Type Parameters

    • T extends IColor3Like

    Parameters

    • otherColor: DeepImmutable<IColor3Like>

      defines the second operand

    • result: T

      defines Color3 object to store the result into

    Returns T

    the unmodified current 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

    • index: number = 0

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

    Returns this

    the current Color3 object

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

    Parameters

    • exact: boolean = false

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

    Returns Color3

    a new Color3 object

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

    Parameters

    • convertedColor: IColor3Like

      defines the Color3 object where to store the gamma space version

    • exact: boolean = false

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

    Returns this

    the unmodified Color3

  • Converts current color in rgb space to HSV values

    Type Parameters

    • T extends IColor3Like

    Parameters

    • result: T

      defines the Color3 where to store the HSV values

    Returns T

    the updated result

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

    Parameters

    • exact: boolean = false

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

    Returns Color3

    a new Color3 object

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

    Parameters

    • convertedColor: IColor3Like

      defines the Color3 object where to store the linear space version

    • exact: boolean = false

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

    Returns this

    the unmodified Color3

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

    Parameters

    • array: DeepImmutable<ArrayLike<number>>

      defines the source array to read from

    • offset: number = 0

      defines the offset in the source array

    • result: Color3

      defines the target Color3 object

    Returns void

  • Converts Hue, saturation and value to a new Color3 (RGB)

    Parameters

    • hue: number

      defines the hue (value between 0 and 360)

    • saturation: number

      defines the saturation (value between 0 and 1)

    • value: number

      defines the value (value between 0 and 1)

    Returns Color3

    a new Color3 object

  • 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

  • Converts Hue, saturation and value to a Color3 (RGB)

    Type Parameters

    • T extends IColor3Like

    Parameters

    • hue: number

      defines the hue (value between 0 and 360)

    • saturation: number

      defines the saturation (value between 0 and 1)

    • value: number

      defines the value (value between 0 and 1)

    • result: T

      defines the Color3 where to store the RGB values

    Returns T

    the updated result