Skip to Content
Kinemium
Datatypes

Colors

Color3, BrickColor, and the sequence types used by gradients and particle colors.

Color3

Color3 stores red, green, and blue channels. Each channel is a number from 0 to 1, so Color3.new(1, 0, 0) is red.

local red = Color3.new(1, 0, 0)
local sky = Color3.fromRGB(120, 180, 255)
local warm = Color3.fromHSV(0.08, 0.9, 1)

print(red:ToHex())
ConstructorDescription
Color3.new(r?, g?, b?)Channels from 0 to 1. All default to 0, which is black.
Color3.fromRGB(r, g, b)Channels from 0 to 255.
Color3.fromHSV(h, s, v)Hue, saturation, and value.
Color3.fromHex(hex)Parses a hex color string. An invalid string raises an error.
MemberTypeDescription
RnumberRed channel.
GnumberGreen channel.
BnumberBlue channel.
MethodReturnsDescription
Lerp(goal, alpha)Color3Interpolates toward goal.
ToHSV()(number, number, number)Hue, saturation, and value.
ToRGB()(number, number, number)Red, green, and blue from 0 to 255.
ToHex()stringHex representation.

The conversions are also available on the library: Color3.toHSV(color), Color3.toRGB(color), and Color3.toHex(color).

Constants:

ConstantValue
Color3.white(1, 1, 1)
Color3.black(0, 0, 0)

Arithmetic supports +, -, unary -, and ==. * and / work with a scalar or another Color3, applying the operation per channel.

BrickColor

BrickColor is the named brick palette. It is separate from Color3, but exposes the equivalent color.

local brick = BrickColor.new("Bright red")
print(brick.Number, brick.Color)
ConstructorDescription
BrickColor.new(number)Looks up a palette entry by number.
BrickColor.new(name)Looks up a palette entry by name.
BrickColor.new(otherBrickColor)Copies an existing value.
BrickColor.random()Picks a color from a small built-in palette.
MemberTypeDescription
NumbernumberPalette number.
NamestringPalette name.
ColorColor3Equivalent RGB color.

Equality compares the palette number.

ColorSequence

A color sequence describes colors over normalized time. Getters return the stops as an array of ColorSequenceKeypoint.

local fade = ColorSequence.new({
    ColorSequenceKeypoint.new(0, Color3.new(1, 0, 0)),
    ColorSequenceKeypoint.new(1, Color3.new(0, 0, 1))
})
ConstructorDescription
ColorSequence.new(color)Constant color for the whole sequence.
ColorSequence.new(startColor, endColor)Two-stop gradient.
ColorSequence.new(keypoints)Sequence from an array of ColorSequenceKeypoint.
MemberTypeDescription
Keypoints{ColorSequenceKeypoint}Read-only array of stops.

ColorSequenceKeypoint

ColorSequenceKeypoint.new(time, color) creates one stop. time must be between 0 and 1; a value outside that range raises an error.

MemberTypeDescription
TimenumberPosition in the sequence, from 0 to 1.
ValueColor3Color at this stop.

Equality compares both fields.

See also

On this page