Raxol.Style.Colors.HSL (Raxol v0.2.0)

View Source

Provides functions for HSL color space conversions and adjustments.

Summary

Functions

Darkens a color by a specified amount (adjusting Lightness).

Desaturates a color by a specified amount (adjusting Saturation).

Converts HSL values to RGB.

Lightens a color by a specified amount (adjusting Lightness).

Converts RGB values to HSL.

Rotates the hue of a color by a specified number of degrees.

Saturates a color by a specified amount (adjusting Saturation).

Functions

darken(color, amount)

Darkens a color by a specified amount (adjusting Lightness).

Parameters

  • color - The color to darken (Color struct)
  • amount - The amount to darken by (0.0 to 1.0)

Returns

  • A Color struct representing the darkened color

desaturate(color, amount)

Desaturates a color by a specified amount (adjusting Saturation).

Parameters

  • color - The color to desaturate (Color struct)
  • amount - The amount to desaturate by (0.0 to 1.0)

Returns

  • A Color struct representing the desaturated color

hsl_to_rgb(h, s, l)

@spec hsl_to_rgb(number(), float(), float()) :: {integer(), integer(), integer()}

Converts HSL values to RGB.

Parameters

  • h, s, l - Hue (0-360), Saturation (0.0-1.0), Lightness (0.0-1.0)

Returns

  • {r, g, b} tuple: Red, Green, Blue values (0-255)

lighten(color, amount)

Lightens a color by a specified amount (adjusting Lightness).

Parameters

  • color - The color to lighten (Color struct)
  • amount - The amount to lighten by (0.0 to 1.0)

Returns

  • A Color struct representing the lightened color

rgb_to_hsl(r, g, b)

@spec rgb_to_hsl(integer(), integer(), integer()) :: {float(), float(), float()}

Converts RGB values to HSL.

Parameters

  • r, g, b - Red, Green, Blue values (0-255)

Returns

  • {h, s, l} tuple: Hue (0-360), Saturation (0.0-1.0), Lightness (0.0-1.0)

rotate_hue(color, degrees)

Rotates the hue of a color by a specified number of degrees.

Parameters

  • color - The color to rotate (Color struct)
  • degrees - The number of degrees to rotate (positive or negative)

Returns

  • A Color struct representing the rotated color

saturate(color, amount)

Saturates a color by a specified amount (adjusting Saturation).

Parameters

  • color - The color to saturate (Color struct)
  • amount - The amount to saturate by (0.0 to 1.0)

Returns

  • A Color struct representing the saturated color