sm.color
Associated object type: 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 new new new new
sm.color.lerp(color1, color2, t)
Linearly interpolates between two colors
Parameters:
| Type | Name | Description |
| Color | color1 | The first color. |
| Color | color2 | The second color. |
| number | t | Interpolation amount between the two inputs. |
Returns:
| Type | Description |
| Color | Interpolated color. |
sm.color.new(color)
Creates a new color object from another color object.
Parameters:
| Type | Name | Description |
| Color | color | The color to copy. |
Returns:
| Type | Description |
| Color | The created color. |
sm.color.new(r, g, b, a?)
Creates a new color object from R, G, B, A.
Parameters:
| Type | Name | Description |
| number | r | The red value. |
| number | g | The green value. |
| number | b | The blue value. |
| number | a? | The alpha value. Defaults to 1.0. (Optional) |
Returns:
| Type | Description |
| Color | The created color. |
sm.color.new(hexStr)
Creates a new color object from a hex string `"RRGGBBAA"`.
Parameters:
| Type | Name | Description |
| string | hexStr | The hex string. |
Returns:
| Type | Description |
| Color | The created color. |
sm.color.new(hexInt)
Creates a new color object from a hex value `0xRRGGBBAA`.
Parameters:
| Type | Name | Description |
| integer | hexInt | The hex value. |
Returns:
| Type | Description |
| Color | The created color. |