Represents a color in the HSL (Hue, Saturation, Lightness) color space. Extends the base Color class.

Hierarchy (View Summary)

Constructors

  • Creates a new HSL color.

    Parameters

    • h: number

      The hue component, in the range [0, 360].

    • s: number

      The saturation component, in the range [0, 100].

    • l: number

      The lightness component, in the range [0, 100].

    • a: number = 1

      The alpha (opacity) component, in the range [0, 1]. Defaults to 1.

    Returns HSL

Methods

  • Returns the HSL color as an array of numbers.

    Returns [number, number, number, number]

    An array containing the hue, saturation, lightness, and alpha components.

  • Converts the color to a hexadecimal string.

    Returns string

    The hexadecimal representation of the color.

  • Returns the HSL color as a CSS-compatible string.

    Returns string

    A string representing the HSL color in CSS format.

  • Blends the color with another color.

    Parameters

    • value: number

      The blend ratio.

    • blendColor: Color

      The color to blend with.

    Returns RGB

    A new RGB color that is blended.

  • Adjusts the brightness of the color.

    Parameters

    • value: number

      The brightness adjustment value.

    Returns RGB

    A new RGB color with adjusted brightness.

  • Creates a copy of the current HSL color.

    Returns HSL

    A new HSL color with the same components as the current color.

  • Adjusts the contrast of the color.

    Parameters

    • value: number

      The contrast adjustment value.

    Returns RGB

    A new RGB color with adjusted contrast.

  • Darkens the color by a given value.

    Parameters

    • value: number

      The amount to darken the color.

    Returns RGB

    A new RGB color that is darkened.

  • Decreases the alpha (opacity) of the HSL color by a given value.

    Parameters

    • value: number

      The value by which to decrease the alpha.

    Returns HSL

    A new HSL color with decreased alpha.

  • Applies gamma correction to the color.

    Parameters

    • value: number

      The gamma correction value.

    Returns RGB

    A new RGB color with gamma correction applied.

  • Lightens the color by a given value.

    Parameters

    • value: number

      The amount to lighten the color.

    Returns RGB

    A new RGB color that is lightened.

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

    Parameters

    • offset: number

      The amount to rotate the hue by, in degrees.

    Returns HSL

    A new HSL color with the hue rotated by the given offset.

  • Returns a new HSL color with rounded components.

    Returns HSL

    A new HSL color with rounded hue, saturation, lightness, and alpha components.

  • Increases the saturation of the HSL color by a given ratio.

    Parameters

    • ratio: number

      The ratio by which to increase the saturation.

    Returns HSL

    A new HSL color with increased saturation.

  • Tints the color by blending it with another color.

    Parameters

    • value: number

      The blend ratio.

    • tintColor: Color

      The color to blend with.

    Returns RGB

    A new RGB color that is tinted.

  • Parses a string or Color object into an HSL color.

    Parameters

    • input: string | Color

      The input string or Color object to parse.

    Returns HSL

    A new HSL color parsed from the input.

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

Properties

a: number

The alpha (opacity) component of the color, in the range [0, 1].

h: number

The hue component of the color, in the range [0, 360].

l: number

The lightness component of the color, in the range [0, 100].

s: number

The saturation component of the color, in the range [0, 100].

HSL: typeof HSL

The HSL color model.

HSV: typeof HSV

The HSV color model.

RGB: typeof RGB

The RGB color model.