Tint
An Elixir library allowing calculations with colors and conversions between different colorspaces.
Currently supports the RGB, CMYK and HSV color models.
Prerequisites
- Erlang 20 or greater
- Elixir 1.8 or greater
Installation
If available in Hex, the package can be installed
by adding tint
to your list of dependencies in mix.exs
:
def deps do
[
{:tint, "~> 0.3"}
]
end
Usage
RGB
iex> Tint.RGB.new(255, 0, 0)
#Tint.RGB<255,0,0>
CMYK
iex> Tint.CMYK.new(0.55, 0.26, 0.24, 0.65)
#Tint.CMYK<55%,26%,24%,65%>
HSV
iex> Tint.HSV.new(25.8, 0.882, 1)
#Tint.HSV<25.8°,88.2%,100%>
Conversion
Between Colorspaces
iex> rgb = Tint.RGB.new(255, 0, 0)
...> Tint.to_hsv(rgb)
#Tint.HSV<0°,100%,100%>
Hex Code
iex> Tint.RGB.from_hex("#FF0000")
{:ok, #Tint.RGB<255,0,0>}
iex> Tint.RGB.from_hex("invalid hex code")
:error
Docs
Documentation can be generated with ExDoc and published on HexDocs. The docs can be found at https://hexdocs.pm/tint.