TinyColor.RGB (tiny_color v0.3.0)

Represents a color in the for of red, green, blue, and optional alpha

Summary

Functions

Returns a string representation of this color. hex is only supported if alpha == 1.0

Functions

Link to this function

new(red, green, blue, alpha \\ 1.0)

Link to this function

percentages(rgb)

Link to this function

to_string(struct, type \\ nil)

Returns a string representation of this color. hex is only supported if alpha == 1.0

Examples

iex> TinyColor.RGB.to_string(%TinyColor.RGB{red: 128.0, green: 129.0, blue: 190.0, alpha: 1.0})
"#8081BE"

iex> TinyColor.RGB.to_string(%TinyColor.RGB{red: 128.0, green: 129.0, blue: 190.0})
"#8081BE"

iex> TinyColor.RGB.to_string(%TinyColor.RGB{red: 128.0, green: 129.0, blue: 190.0, alpha: 0.5})
"rgba(128, 129, 190, 0.5)"

iex> TinyColor.RGB.to_string(%TinyColor.RGB{red: 128.0, green: 129.0, blue: 190.0}, :hex)
"#8081BE"

iex> TinyColor.RGB.to_string(%TinyColor.RGB{red: 128.0, green: 129.0, blue: 190.0, alpha: 1.0}, :hex)
"#8081BE"

iex> TinyColor.RGB.to_string(%TinyColor.RGB{red: 128.0, green: 129.0, blue: 190.0, alpha: 0.5}, :hex)
"#8081BE80"

iex> TinyColor.RGB.to_string(%TinyColor.RGB{red: 128.0, green: 129.0, blue: 190.0}, :rgb)
"rgb(128, 129, 190)"

iex> TinyColor.RGB.to_string(%TinyColor.RGB{red: 128.0, green: 129.0, blue: 190.0, alpha: 1.0}, :rgb)
"rgb(128, 129, 190)"

iex> TinyColor.RGB.to_string(%TinyColor.RGB{red: 128.0, green: 129.0, blue: 190.0}, :rgba)
"rgba(128, 129, 190, 1.0)"

iex> TinyColor.RGB.to_string(%TinyColor.RGB{red: 128.0, green: 129.0, blue: 190.0, alpha: 1.0}, :rgba)
"rgba(128, 129, 190, 1.0)"

iex> TinyColor.RGB.to_string(%TinyColor.RGB{red: 128.0, green: 129.0, blue: 190.0, alpha: 0.5}, :rgba)
"rgba(128, 129, 190, 0.5)"