CSSEx.HSLA (CSSEx v0.8.0) View Source

Struct and helper functions for generating HSLA values.

Link to this section Summary

Functions

Converts an existing %CSSEx.RGBA{} struct into a %CSSEx.HSLA{} struct. Taken from https://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/

Generates a %CSSEx.HSLA{} wrapped in an :ok tuple, from the values of h, s, l, and alpha. All values are treated as decimal.

Accepts any value in the form of a binary "hsla(0, 10%, 20%, 0.5)" or "hsl(0, 10%, 20%)", any hexadecimal representation in binary in the form of "#xxx", "#xxxx", "#xxxxxx" or "#xxxxxxxx", rgb/a as "rgba(100,100,100,0.1)" or "rgb(10,20,30)", or any literal color name defined as web colors (CSSEx.Colors) - returns a %CSSEx.HSLA{} struct.

Link to this section Types

Link to this section Functions

Specs

from_rgba(%CSSEx.RGBA{a: term(), b: term(), g: term(), r: term()}) ::
  {:ok, %CSSEx.HSLA{a: term(), h: term(), l: term(), s: term()}}

Converts an existing %CSSEx.RGBA{} struct into a %CSSEx.HSLA{} struct. Taken from https://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/

Generates a %CSSEx.HSLA{} wrapped in an :ok tuple, from the values of h, s, l, and alpha. All values are treated as decimal.

Specs

new_hsla(String.t()) ::
  {:ok, %CSSEx.HSLA{a: term(), h: term(), l: term(), s: term()}}
  | {:error, term()}

Accepts any value in the form of a binary "hsla(0, 10%, 20%, 0.5)" or "hsl(0, 10%, 20%)", any hexadecimal representation in binary in the form of "#xxx", "#xxxx", "#xxxxxx" or "#xxxxxxxx", rgb/a as "rgba(100,100,100,0.1)" or "rgb(10,20,30)", or any literal color name defined as web colors (CSSEx.Colors) - returns a %CSSEx.HSLA{} struct.