gophergfx
    Preparing search index...

    Class Color

    This class holds a color for computer graphics defined via four components (Red, Green, Blue, Alpha). Alpha is opacity (0.0 = completely transparent, 1.0 = completely opaque). All components range from 0.0 to 1.0 in floating point.

    Index
    • Constructor for creating a Color object

      Parameters

      • r: number = 0

        The red component of the Color object

      • g: number = 0

        The green component of the Color object

      • b: number = 0

        The blue component of the Color object

      • a: number = 1

        The alpha component of the Color object

      Returns Color

    a: number
    b: number
    g: number
    r: number
    BLACK: Color = ...
    BLUE: Color = ...
    CYAN: Color = ...
    GREEN: Color = ...
    PURPLE: Color = ...
    RED: Color = ...
    WHITE: Color = ...

    Static properties representing standard colors

    YELLOW: Color = ...
    • Add another Color object to the current one

      Parameters

      • c: Color

        The Color object to add

      Returns void

    • Create a clone of the Color object

      Returns Color

      A new Color object that is an exact copy of the original

    • Copy the components of a given Color object

      Parameters

      • color: Color

        The Color object to copy

      Returns void

    • Divide the current Color object by another one

      Parameters

      • c: Color

        The Color object to divide by

      Returns void

    • Method that divides a Color object by a scalar

      Parameters

      • n: number

        The scalar to divide the Color object by

      Returns void

    • Interpolate between two Color objects

      Parameters

      • c1: Color

        The first Color object

      • c2: Color

        The second Color object

      • alpha: number

        The interpolation factor between the two objects

      Returns void

    • Multiply the current Color object by another one

      Parameters

      • c: Color

        The Color object to multiply by

      Returns void

    • Multiply the current Color object by a scalar

      Parameters

      • n: number

        The scalar to multiply by

      Returns void

    • Set the components of the Color object

      Parameters

      • r: number = 0

        The red component

      • g: number = 0

        The green component

      • b: number = 0

        The blue component

      • a: number = 1

        The alpha component (optional, defaults to 1)

      Returns void

    • Set the components of the Color object from a hex string

      Parameters

      • color: string

        The hex string to convert to a Color object

      Returns void

    • Subtract another Color object from the current one

      Parameters

      • c: Color

        The Color object to subtract

      Returns void

    • Static method to create a clone of the given Color object

      Parameters

      • color: Color

        The Color object to clone

      Returns Color

      A clone of the given Color object

    • Static method to create a Color object from a hex string

      Parameters

      • color: string

        The hex string to convert to a Color object

      Returns Color

      A new Color object created from the given hex string

    • Static method to divide two Color objects

      Parameters

      • c1: Color

        The first Color object

      • c2: Color

        The second Color object

      Returns Color

      The quotient of the two Color objects

    • Static method that calculates the result of dividing a Color by a scalar

      Parameters

      • v: Color

        The Color object to be divided

      • n: number

        The scalar to divide the Color by

      Returns Color

      The result of the division

    • Static method to interpolate between two Color objects

      Parameters

      • c1: Color

        The first Color object

      • c2: Color

        The second Color object

      • alpha: number

        The interpolation factor between the two objects

      Returns Color

      The interpolated Color object

    • Static method to multiply two Color objects

      Parameters

      • c1: Color

        The first Color object

      • c2: Color

        The second Color object

      Returns Color

      The product of the two Color objects

    • Static method to multiply a Color object by a scalar

      Parameters

      • v: Color

        The Color object to multiply

      • n: number

        The scalar to multiply by

      Returns Color

      The product of the Color object and the scalar

    • Static method to subtract two Color objects

      Parameters

      • c1: Color

        The first Color object

      • c2: Color

        The second Color object

      Returns Color

      The difference between the two Color objects