An open API service indexing awesome lists of open source software.

https://github.com/rafalgolarz/claritas

Generate different variations of brightness for the given color.
https://github.com/rafalgolarz/claritas

colors elixir elixir-lang hex package

Last synced: 8 months ago
JSON representation

Generate different variations of brightness for the given color.

Awesome Lists containing this project

README

          

# Claritas

[![Hex.pm](https://img.shields.io/hexpm/v/claritas.svg?maxAge=2592000)](https://hex.pm/packages/claritas)
[![Downloads](https://img.shields.io/hexpm/dt/claritas.svg?maxAge=3600)](https://hex.pm/packages/claritas)
[![Build Status](https://travis-ci.org/rafalgolarz/claritas.svg?branch=master)](https://travis-ci.org/rafalgolarz/claritas)

Library for generating different variations of brightness for given color.

## Installation

The package can be installed by adding `claritas` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:claritas, "~> 0.1.1"}
]
end
```

and running `mix deps.get` in your console to fetch from Hex.

## Basic Usage

### positive values are lightening the color

```
iex> Claritas.shift("#f06d06", 30)
{:ok, "#FF8B24"}
```

### negative values are darkening the color

```
iex> Claritas.shift("#f06d06", -30)
{:ok, "#D24F00"}
```

### Dynamically increase/decrease brightness of your colors.

Controller:

```
def index(conn, _params) do
shades =
for i <- 1..20, into: [] do
Claritas.shift("#141C5B", 10 * i)
end

render(conn, "index.html", shades: shades)
end
```

Template:

```


    <%= for {_, shade} <- @shades do %>
  • <%= shade %>

  • <% end %>

```

Output:

## Author
Rafał Golarz

Claritas is released under the [MIT License](https://github.com/rafalgolarz/claritas/blob/master/LICENSE.txt).