sm.color

A color is represented using a red, green, blue and alpha component. Colors are prominently used for blocks and parts that are colored by the Paint Tool.

To create one, use sm.color.new. It is possible to use hex 0xRRGGBBAA or strings "RRGGBBAA".

Note: R, G, B, A values range between 0.0–1.0.

Functions

lerp

sm.color.lerp( color1, color2, t )

Linearly interpolates between two colors

Parameters:

Name Type Description
color1 Color The first color.
color2 Color The second color.
t number Interpolation amount between the two inputs.

Returns:

Type Description
Color Interpolated color.

new - Color

sm.color.new( color )

Creates a new color object from another color object.

Parameters:

Name Type Description
color Color The color to copy.

Returns:

Type Description
Color The created color.

new - number

sm.color.new( r, g, b, a )

Creates a new color object from R, G, B, A.

Parameters:

Name Type Description
r number The red value.
g number The green value.
b number The blue value.
a (optional) number The alpha value. Defaults to 1.0. (Optional)

Returns:

Type Description
Color The created color.

new - hexStr

sm.color.new( hexStr )

Creates a new color object from a hex string "RRGGBBAA".

Parameters:

Name Type Description
hexStr string The hex string.

Returns:

Type Description
Color The created color.

new - hexInt

sm.color.new( hexInt )

Creates a new color object from a hex value 0xRRGGBBAA.

Parameters:

Name Type Description
hexInt integer The hex value.

Returns:

Type Description
Color The created color.