Skip to content
A library allowing calculations with colors and conversions between different colorspaces
Elixir
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Setup project Sep 13, 2019
lib refactor: improve implementation of interval formatter Oct 10, 2019
test
.credo.exs Setup project Sep 13, 2019
.dialyzer_ignore.exs docs: add some docs Sep 13, 2019
.formatter.exs Setup project Sep 13, 2019
.gitignore Setup project Sep 13, 2019
.tool-versions Update Erlang in .tool-versions Sep 16, 2019
.travis.yml chore: Add Elixir 1.7 to supported versions in travis config Sep 15, 2019
README.md chore: update readme Oct 10, 2019
coveralls.json Setup project Sep 13, 2019
mix.exs chore: Bump version Sep 18, 2019
mix.lock chore: Update Inch Sep 16, 2019

README.md

Tint

Build Status Coverage Status Hex.pm

An Elixir library allowing calculations with colors and conversions between different colorspaces.

Currently supports the RGB, CMYK and HSV color models.

Prerequisites

  • Elixir 1.7 or greater

Installation

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
iex> Tint.RGB.to_hex(Tint.RGB.new(255, 0, 0))
"#FF0000"

Docs

The API docs can be found at HexDocs.

You can’t perform that action at this time.