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:

    TypeNameDescription
    Colorcolor1The first color.
    Colorcolor2The second color.
    numbertInterpolation amount between the two inputs.

    Returns:

    TypeDescription
    ColorInterpolated color.

    sm.color.new(color)

    Creates a new color object from another color object.

    Parameters:

    TypeNameDescription
    ColorcolorThe color to copy.

    Returns:

    TypeDescription
    ColorThe created color.

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

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

    Parameters:

    TypeNameDescription
    numberrThe red value.
    numbergThe green value.
    numberbThe blue value.
    numbera?The alpha value. Defaults to 1.0. (Optional)

    Returns:

    TypeDescription
    ColorThe created color.

    sm.color.new(hexStr)

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

    Parameters:

    TypeNameDescription
    stringhexStrThe hex string.

    Returns:

    TypeDescription
    ColorThe created color.

    sm.color.new(hexInt)

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

    Parameters:

    TypeNameDescription
    integerhexIntThe hex value.

    Returns:

    TypeDescription
    ColorThe created color.