Raxol. Style. Colors. HSL
(Raxol v2.6.0)
View Source
Provides functions for HSL color space conversions and adjustments.
This is the single source of truth for RGB<->HSL conversions. Other modules should delegate here instead of reimplementing.
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).
Normalizes a hue value to the range [0, 360).
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
@spec darken(Raxol.Style.Colors.Color.t(), float()) :: Raxol.Style.Colors.Color.t()
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
@spec desaturate(Raxol.Style.Colors.Color.t(), float()) :: Raxol.Style.Colors.Color.t()
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
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)
@spec lighten(Raxol.Style.Colors.Color.t(), float()) :: Raxol.Style.Colors.Color.t()
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
Normalizes a hue value to the range [0, 360).
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)
@spec rotate_hue(Raxol.Style.Colors.Color.t(), number()) :: Raxol.Style.Colors.Color.t()
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
@spec saturate(Raxol.Style.Colors.Color.t(), float()) :: Raxol.Style.Colors.Color.t()
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