View Source CSSEx.HSLA (CSSEx v1.0.1)
Struct and helper functions for generating HSLA values.
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.
Types
@type t() :: %CSSEx.HSLA{ a: non_neg_integer(), h: non_neg_integer(), l: non_neg_integer(), s: non_neg_integer() }
Functions
@spec 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.
@spec 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.