vivid v0.1.1 Vivid.RGBA

Defines a colour in RGBA colour space.

Summary

Functions

Return the alpha component of the colour

Shorthand for black

Return the blue component of the colour

Return the green component of the colour

Create a colour. Like magic

Return the luminance of a colour, using some colour mixing ratios I found on stack exchange

Blend two colours together using their alpha information using the “over” algorithm

Return the red component of the colour

Convert a colour to HTML style hex

Shorthand for white

Functions

alpha(r_g_b_a)

Return the alpha component of the colour.

Example

iex> Vivid.RGBA.init(0.7, 0.6, 0.5, 0.4)
...> |> Vivid.RGBA.alpha
0.4
black()

Shorthand for black.

Example

iex> Vivid.RGBA.black
#Vivid.RGBA<{0, 0, 0, 1}>
blue(r_g_b_a)

Return the blue component of the colour.

Example

iex> Vivid.RGBA.init(0.7, 0.6, 0.5, 0.4)
...> |> Vivid.RGBA.blue
0.5
green(r_g_b_a)

Return the green component of the colour.

Example

iex> Vivid.RGBA.init(0.7, 0.6, 0.5, 0.4)
...> |> Vivid.RGBA.green
0.6
init(red, green, blue)

Create a colour. Like magic.

Example

iex> Vivid.RGBA.init(0.1, 0.2, 0.3, 0.4)
#Vivid.RGBA<{0.1, 0.2, 0.3, 0.4}>
init(red, green, blue, alpha)
luminance(r_g_b_a)

Return the luminance of a colour, using some colour mixing ratios I found on stack exchange.

Examples

iex> Vivid.RGBA.init(1,0,0) |> Vivid.RGBA.luminance
0.2128

iex> Vivid.RGBA.white |> Vivid.RGBA.luminance
1.0

iex> Vivid.RGBA.black |> Vivid.RGBA.luminance
0.0
over(visible, colour)

Blend two colours together using their alpha information using the “over” algorithm.

Examples

iex> Vivid.RGBA.over(Vivid.RGBA.black, Vivid.RGBA.init(1,1,1, 0.5))
#Vivid.RGBA<{0.5, 0.5, 0.5, 1.0}>
red(r_g_b_a)

Return the red component of the colour.

Example

iex> Vivid.RGBA.init(0.7, 0.6, 0.5, 0.4)
...> |> Vivid.RGBA.red
0.7
to_ascii(colour)
to_hex(r_g_b_a)

Convert a colour to HTML style hex.

Example

iex> Vivid.RGBA.init(0.7, 0.6, 0.5)
...> |> Vivid.RGBA.to_hex
"#B39980"
white()

Shorthand for white.

Example

iex> Vivid.RGBA.white
#Vivid.RGBA<{1, 1, 1, 1}>