Represents an RGB color with optional alpha transparency.

Hierarchy (View Summary)

Constructors

  • Creates an instance of RGB.

    Parameters

    • r: number

      Red component (0-255).

    • g: number

      Green component (0-255).

    • b: number

      Blue component (0-255).

    • a: number = 1

      Alpha component (0-1), defaults to 1.

    Returns RGB

Methods

  • Returns the RGB color as an array.

    Returns [number, number, number, number]

    An array containing the red, green, blue, and alpha components.

  • Returns the RGB color as a hexadecimal string.

    Returns string

    A string representation of the RGB color in hexadecimal format.

  • Returns the RGB color as a string.

    Returns string

    A string representation of the RGB color in either rgb or rgba format.

  • Blends the RGB color with another color.

    Parameters

    • value: number

      The blend value to apply.

    • blendColor: Color

      The color to blend with.

    Returns RGB

    A new RGB instance with the blended color.

  • Adjusts the brightness of the RGB color.

    Parameters

    • value: number

      The brightness value to apply.

    Returns RGB

    A new RGB instance with the adjusted brightness.

  • Adjusts the contrast of the RGB color.

    Parameters

    • value: number

      The contrast value to apply.

    Returns RGB

    A new RGB instance with the adjusted contrast.

  • Darkens the RGB color.

    Parameters

    • ratio: number

      The ratio to darken the color by.

    Returns RGB

    A new RGB instance with the darkened color.

  • Fades the RGB color by reducing its alpha value.

    Parameters

    • value: number

      The fade value to apply.

    Returns RGB

    A new RGB instance with the faded color.

  • Adjusts the gamma of the RGB color.

    Parameters

    • value: number

      The gamma value to apply.

    Returns RGB

    A new RGB instance with the adjusted gamma.

  • Lightens the RGB color.

    Parameters

    • ratio: number

      The ratio to lighten the color by.

    Returns RGB

    A new RGB instance with the lightened color.

  • Rotates the hue of the color by a given offset.

    Parameters

    • offset: number

      The amount to rotate the hue.

    Returns HSL

    A new HSL color with the hue rotated.

  • Rounds the RGB color components to the nearest integer.

    Returns RGB

    A new RGB instance with rounded color values.

  • Saturates the color by a given ratio.

    Parameters

    • ratio: number

      The ratio to saturate the color.

    Returns HSL

    A new HSL color with increased saturation.

  • Tints the RGB color with another color.

    Parameters

    • value: number

      The tint value to apply.

    • tintColor: Color

      The color to use for tinting.

    Returns RGB

    A new RGB instance with the applied tint.

  • Parses a string or Color instance into an RGB color.

    Parameters

    • input: string | Color

      The input string or Color instance to parse.

    Returns RGB

    A new RGB instance representing the parsed color.

    Will throw an error if the input string is not a valid RGB color string.

Properties

a: number

Alpha component (0-1).

b: number

Blue component (0-255).

g: number

Green component (0-255).

r: number

Red component (0-255).

HSL: typeof HSL

The HSL color model.

HSV: typeof HSV

The HSV color model.

RGB: typeof RGB

The RGB color model.