dcrck

dcrck

Ultraviolet is an Elixir color manipulation library designed to work like chroma-js. It does not have full parity with chroma-js, but it includes most of the common operations and features.

Getting started

Here are a few things it can do:

  • read colors from a wide range of inputs
  • analyze and manipulate colors
  • convert colors into a wide range of formats
  • linear, bezier, and custom interpolation in different color spaces

Here’s an example of a simple read / manipulate / output chain

{:ok, color} = Ultraviolet.new("pink")

color
|> Ultraviolet.Color.darken!()
|> Ultraviolet.Color.saturate!(2)
|> Ultraviolet.Color.hex()
#=> "#ff6d93"

Aside from that, ultraviolet can help you generate nice colors using various methods. These colors can be used, for example, as a color palette for maps or data visualization.

{:ok, scale} = Ultraviolet.scale(["#fafa6e", "#2a4858"], space: :lch)
colors = Ultraviolet.Scale.take(scale, 6)

This library has a lot more to offer, though; the documentation contains more examples of how to use it.


Background

I’m working on a project that requires creating nice-looking gradients and other cover images. I explored a number of related tools online, such as Cool Backgrounds and Trianglify. I noticed that pretty much all of them use chroma-js for color manipulation, so I took a look at the library. I was pleasantly surprised: the API is functional and well-documented with plenty of examples and test cases. I also noticed that there wasn’t a fully-featured color manipulation library in Elixir yet, so I felt the urge to try porting some of chroma.js over to Elixir to use with the project (a Phoenix website).

That was last Thursday. Since then, I’ve brought over most of the core chroma-js functionality, but made some API adjustments so it better fits the “Elixir style”. It’s not quite “finished” yet, and I probably need to do more testing and fine-tuning, but I feel like it’s robust and stable enough that I can release it as a library. If you need to manipulate colors for your app, please give ultraviolet a try and let me know what you think!

Acknowledgements

Huge thanks to the chroma.js creator for making such a wonderful and well-documented library. If you haven’t seen the chroma-js documentation, I’d recommend giving it a read.

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
CodeSync
:microphone: ElixirConf 2026 - Call for Talks is open! We’re heading to Chicago :united_states: :round_pushpin: In person + virtual :d...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews