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:
sm.color.new(r, g, b, a=nil)
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=nil | 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. |