ProtoTwin API
    Preparing search index...

    Class Color

    Immutable RGB color.

    Index

    Constructors

    • Constructor.

      Parameters

      • r: number

        The red channel [0, 1].

      • g: number

        The green channel [0, 1].

      • b: number

        The blue channel [0, 1].

      Returns Color

    Properties

    b: number

    The blue channel [0, 1].

    g: number

    The green channel [0, 1].

    r: number

    The red channel [0, 1].

    Accessors

    Methods

    • Calculates the closest hexadecimal code.

      Returns string

      Hexadecimal code as a string in the HTML format, including the "#".

    • Determines whether two colors are exactly equal.

      Parameters

      • start: Color

        The first color.

      • end: Color

        The second color.

      Returns boolean

      True if the colors are equal, false otherwise.

    • Creates a color from a hexadecimal code.

      Parameters

      • value: string

        The hexadecimal code.

      Returns Color

      The corresponding color.

    • Decodes a 32-bit integer to a color.

      Parameters

      • value: number

        The encoded color.

      Returns Color

      The decoded color.

    • Linearly interpolates between two colors in RGB space.

      Parameters

      • start: Color

        The start color.

      • end: Color

        The end color.

      • weight: number

        The interpolation fraction between the two colors.

      Returns Color

      The interpolated color.

    • Linearly interpolates between two colors in HSL space.

      Parameters

      • start: Color

        The start color.

      • end: Color

        The end color.

      • weight: number

        The interpolation fraction between the two colors.

      Returns Color

      The interpolated color.

    • Linearly interpolates between two colors in HSV space.

      Parameters

      • start: Color

        The start color.

      • end: Color

        The end color.

      • weight: number

        The interpolation fraction between the two colors.

      Returns Color

      The interpolated color.

    • Creates a random color.

      Returns Color

      The random color.

    • Encodes a color to a 32-bit integer.

      Parameters

      • r: number

        The red channel [0, 1].

      • g: number

        The green channel [0, 1].

      • b: number

        The blue channel [0, 1].

      • a: number

        The alpha channel [0, 1].

      Returns number

      The encoded color.