Class Color3
Implements
- Tensor<Tuple<number, 3>, IColor3Like>
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
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
- r: number = 0
Properties
b
[0] Defines the blue component (between 0 and 1, default is 0)
Readonlydimension
g
[0] Defines the green component (between 0 and 1, default is 0)
r
[0] Defines the red component (between 0 and 1, default is 0)
Readonlyrank
Static_ V8 Performance Hack
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.
Accessors
StaticBlack Read Only
-
Gets a Color3 value containing a black color that must not be updated
Returns DeepImmutable<Color3>
Methods
add
-
Creates a new Color3 set with the added values of the current Color3 and of the given one
Parameters
- otherColor: DeepImmutable<IColor3Like>
defines the second operand
Returns Color3
the new Color3
- otherColor: DeepImmutable<IColor3Like>
add In Place
-
Adds the given color to the current Color3
Parameters
- otherColor: DeepImmutable<IColor3Like>
defines the second operand
Returns this
the current updated Color3
- otherColor: DeepImmutable<IColor3Like>
add In Place From Floats
-
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
- r: number
add To Ref
-
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
as Array
-
Returns a new array populated with 3 numeric elements : red, green and blue values
Returns [number, number, number]
the new array
clamp To Ref
-
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
clone
copy From
-
Copies the rgb values from the source in the current Color3
Parameters
- source: DeepImmutable<IColor3Like>
defines the source Color3 object
Returns this
the updated Color3 object
- source: DeepImmutable<IColor3Like>
copy From Floats
-
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
- r: number
equals
-
Determines equality between Color3 objects
Parameters
- otherColor: DeepImmutable<IColor3Like>
defines the second operand
Returns boolean
true if the rgb values are equal to the given ones
- otherColor: DeepImmutable<IColor3Like>
equals Floats
-
Alias for equalsToFloats
Parameters
- r: number
red color component
- g: number
green color component
- b: number
blue color component
Returns boolean
boolean
- r: number
equals To Floats
-
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
- r: number
equals With Epsilon
-
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
- otherColor: DeepImmutable<IColor3Like>
from Array
-
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
- array: DeepImmutable<ArrayLike<number>>
from Hex String
-
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
- hex: string
get Class Name
-
Returns the string "Color3"
Returns string
"Color3"
get Hash Code
-
Compute the Color3 hash code
Returns number
an unique number that can be used to hash Color3 objects
maximize In Place
-
Updates the current Color3 with the maximal coordinate values between its and the given color ones.
Parameters
- other: DeepImmutable<IColor3Like>
defines the second operand
Returns this
the current updated Color3
- other: DeepImmutable<IColor3Like>
maximize In Place From Floats
-
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
- r: number
minimize In Place
-
Updates the current Color3 with the minimal coordinate values between its and the given color ones
Parameters
- other: DeepImmutable<IColor3Like>
defines the second operand
Returns this
the current updated Color3
- other: DeepImmutable<IColor3Like>
minimize In Place From Floats
-
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
- r: number
multiply
-
Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
Parameters
- otherColor: DeepImmutable<IColor3Like>
defines the second operand
Returns Color3
the new Color3 object
- otherColor: DeepImmutable<IColor3Like>
multiply By Floats
-
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
- r: number
multiply In Place
-
Multiplies the current Color3 coordinates by the given ones
Parameters
- otherColor: DeepImmutable<IColor3Like>
defines the second operand
Returns this
the current updated Color3
- otherColor: DeepImmutable<IColor3Like>
multiply To Ref
-
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
-
Creates a new Color3 with the current Color3 values multiplied by scale
Parameters
- scale: number
defines the scaling factor to apply
Returns Color3
a new Color3 object
- scale: number
scale And Add To Ref
scale In Place
-
Multiplies the Color3 values by the float "scale"
Parameters
- scale: number
defines the scaling factor to apply
Returns this
the current updated Color3
- scale: number
scale To Ref
set
-
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
- r: number
set All
-
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
- v: number
subtract
-
Returns a new Color3 set with the subtracted values of the given one from the current Color3
Parameters
- otherColor: DeepImmutable<IColor3Like>
defines the second operand
Returns Color3
the new Color3
- otherColor: DeepImmutable<IColor3Like>
subtract From Floats
-
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
- r: number
subtract From Floats To Ref
-
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
subtract In Place
-
Subtract the given color from the current Color3
Parameters
- otherColor: DeepImmutable<IColor3Like>
defines the second operand
Returns this
the current updated Color3
- otherColor: DeepImmutable<IColor3Like>
subtract To Ref
-
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
to Array
-
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
- array: FloatArray
to Color4
-
Returns a new Color4 object from the current Color3 and the given alpha
Parameters
- alpha: number = 1
defines the alpha component on the new Color4 object (default is 1)
Returns Color4
a new Color4 object
- alpha: number = 1
to Gamma Space
-
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
- exact: boolean = false
to Gamma Space To Ref
-
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
- convertedColor: IColor3Like
to Hex String
-
Compute the Color3 hexadecimal code as a string
Returns string
a string containing the hexadecimal representation of the Color3 object
to HSV
-
Converts current color in rgb space to HSV values
Returns Color3
a new color3 representing the HSV values
to HSV To Ref
to Linear Space
-
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
- exact: boolean = false
to Linear Space To Ref
-
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
- convertedColor: IColor3Like
to Luminance
-
Returns the luminance value
Returns number
a float value
to String
-
Creates a string with the Color3 current values
Returns string
the string representation of the Color3 object
StaticBlack
StaticBlue
StaticFrom Array
-
Creates a new Color3 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 Color3
a new Color3 object
- array: DeepImmutable<ArrayLike<number>>
StaticFrom Array To Ref
-
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
- array: DeepImmutable<ArrayLike<number>>
StaticFrom Hex String
-
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
- hex: string
StaticFrom HSV
-
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
- hue: number
StaticFrom Ints
-
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
- r: number
StaticGray
StaticGreen
StaticHermite
-
Hermite(
value1: DeepImmutable<Color3>,
tangent1: DeepImmutable<Color3>,
value2: DeepImmutable<Color3>,
tangent2: DeepImmutable<Color3>,
amount: number,
): Color3Returns a new Color3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
Parameters
- value1: DeepImmutable<Color3>
defines the first control point
- tangent1: DeepImmutable<Color3>
defines the first tangent Color3
- value2: DeepImmutable<Color3>
defines the second control point
- tangent2: DeepImmutable<Color3>
defines the second tangent Color3
- amount: number
defines the amount on the interpolation spline (between 0 and 1)
Returns Color3
the new Color3
- value1: DeepImmutable<Color3>
StaticHermite1st Derivative
-
Hermite1stDerivative(
value1: DeepImmutable<Color3>,
tangent1: DeepImmutable<Color3>,
value2: DeepImmutable<Color3>,
tangent2: DeepImmutable<Color3>,
time: number,
): Color3Returns a new Color3 which is the 1st derivative of the Hermite spline defined by the colors "value1", "value2", "tangent1", "tangent2".
Parameters
- value1: DeepImmutable<Color3>
defines the first control point
- tangent1: DeepImmutable<Color3>
defines the first tangent
- value2: DeepImmutable<Color3>
defines the second control point
- tangent2: DeepImmutable<Color3>
defines the second tangent
- time: number
define where the derivative must be done
Returns Color3
1st derivative
- value1: DeepImmutable<Color3>
StaticHermite1st Derivative To Ref
-
Hermite1stDerivativeToRef(
value1: DeepImmutable<Color3>,
tangent1: DeepImmutable<Color3>,
value2: DeepImmutable<Color3>,
tangent2: DeepImmutable<Color3>,
time: number,
result: Color3,
): voidReturns a new Color3 which is the 1st derivative of the Hermite spline defined by the colors "value1", "value2", "tangent1", "tangent2".
Parameters
- value1: DeepImmutable<Color3>
defines the first control point
- tangent1: DeepImmutable<Color3>
defines the first tangent
- value2: DeepImmutable<Color3>
defines the second control point
- tangent2: DeepImmutable<Color3>
defines the second tangent
- time: number
define where the derivative must be done
- result: Color3
define where to store the derivative
Returns void
- value1: DeepImmutable<Color3>
StaticHS Vto RGB To Ref
-
HSVtoRGBToRef<T extends IColor3Like>(
hue: number,
saturation: number,
value: number,
result: T,
): TConverts 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
StaticLerp
-
Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
Parameters
- start: DeepImmutable<Color3>
defines the start Color3 value
- end: DeepImmutable<Color3>
defines the end Color3 value
- amount: number
defines the gradient value between start and end
Returns Color3
a new Color3 object
- start: DeepImmutable<Color3>
StaticLerp To Ref
-
LerpToRef(
left: DeepImmutable<Color3>,
right: DeepImmutable<Color3>,
amount: number,
result: Color3,
): voidCreates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
Parameters
- left: DeepImmutable<Color3>
defines the start value
- right: DeepImmutable<Color3>
defines the end value
- amount: number
defines the gradient factor
- result: Color3
defines the Color3 object where to store the result
Returns void
- left: DeepImmutable<Color3>
Class used to hold a RGB color