View Source Ultraviolet.Color.HSL (Ultraviolet v0.1.1)

Functions for working in the HSL color space.

Summary

Types

t()

Defines the channels in an HSL color.

Functions

Converts a Color to HSL

Generates a new HSL color object

Generates a new HSL color object

Generates a new HSL color object

Converts from HSL to an RGB Color object

Types

@type t() :: %Ultraviolet.Color.HSL{
  a: number(),
  h: number(),
  l: number(),
  s: number()
}

Defines the channels in an HSL color.

Functions

Link to this function

from_rgb(color, options \\ [])

View Source
@spec from_rgb(Ultraviolet.Color.t(), list()) :: {:ok, t()}

Converts a Color to HSL

conversion taken from https://wikipedia.org/wiki/HSL_color_space

@spec new(tuple() | [number()] | map() | [...]) :: {:ok, t()}

Generates a new HSL color object

iex>Ultraviolet.Color.HSL.new({60, 0.0, 0.5})
{:ok, %Ultraviolet.Color.HSL{h: 60, s: 0.0, l: 0.5}}
@spec new(number(), number(), number()) :: {:ok, t()}

Generates a new HSL color object

iex>Ultraviolet.Color.HSL.new(60, 0.0, 0.5)
{:ok, %Ultraviolet.Color.HSL{h: 60, s: 0.0, l: 0.5}}
@spec new(number(), number(), number(), number()) :: {:ok, t()}

Generates a new HSL color object

iex>Ultraviolet.Color.HSL.new(60, 0.0, 0.5, 0.5)
{:ok, %Ultraviolet.Color.HSL{h: 60, s: 0.0, l: 0.5, a: 0.5}}
@spec to_rgb(t()) :: {:ok, Ultraviolet.Color.t()}

Converts from HSL to an RGB Color object

conversion taken from https://wikipedia.org/wiki/HSL_color_space

Options

  • :round: an integer if rounding r, g, and b channel values to N decimal places is desired; if no rounding is desired, pass false. Default: 0
@spec to_rgb(t(), list()) :: {:ok, Ultraviolet.Color.t()}