Colour algorithms

Hey, I have a problem to find all helpful sources, so I’m asking here if you already worked on it and/or have a link for useful resource.

What I’m looking on:

  1. All colour standards that are used now (like RGB).
  2. All algorithms to convert between all of them + info if it’s not possible directly between A and B.
  3. All algorithms that are used now for colour manipulation (like invert, sepia)

For now I have implemented:

  1. HEX, HSL and RGB - all with alpha
  2. Known convertions:
    a) HEX -> RGB
    b) HSL -> RGB
    c) RGB -> HEX
    d) RGB -> HSL
    e) no HEX <=> HSL - reason: requires RGB
  3. I have few algorithms for grayscale and sepia, but I don’t know how to apply them in percentage.

I found this page which allow preview of CSS filters. I would like to have algorithms for them and even more (if any). Of course some of them (like shadow) applies to whole image and I’m looking for algorithms for manipulating of single colors (like sepia).

Extra request!
I know easy algorithm for RGB to make colour inverted:

{red, green, blue} = {255, 255, 255}
inverted_red = 255 - red
inverted_green = 255 - green
inverted_blue = 255 - blue

but I heard about something like spitting palette into planes and inverting colour with keeping plane. Do you know how it works?

All of them I plan to implement in one of my libraries.

There’s also the Lab and CMYK color space.

As you seem to be working on color manipulations as well. I’d like to see an implementation of the ideas shown here for darkening or lightening colors https://medium.com/@erikdkennedy/color-in-ui-design-a-practical-framework-e18cacd97f9e

1 Like

This might be helpful https://github.com/jfairbank/chroma

1 Like

@LostKobrakai: I heard about CMYK, but don’t have a time to research about it.
I was focused on HEX, HSL and RGB, because they are used in CSS and it’s why I want to finish them first. Later I will look at them.
Darkening and Lightening will be of course supported. After conversion there will be one of the most important features.

@amnu3387: Great! I know Ruby, so I will take a look at its code. To be honest I could think about it before posting.
Pallets are really interesting idea. I will definitely try it.

Yeah, it can generate full palettes but I’ve mostly used it to create variations on colors (in order to create “themes” from users inputs)

CMYK is easy, as it maps straightforward to RGB (K is blacK and is easily calculated).

Lab is a good colour model for lightening and darkening since the luminance channel (the “L”) is separated from the two colour channels.

I build a Ruby lib similar to what you are doing a loooong time ago (https://github.com/kipcole9/rainbow) and found http://www.workwithcolor.com/color-theory-introduction-4619.htm was helpful (plus the other content on that site). I never finished it - its about the time I started working in Elixir and haven’t been back.

  • In the data directory of that lib are a bunch of resources describing colour definitions in different spaces that may be useful.

  • wheel.rb has a bunch of “common” colour transformations (complement, triadic, split complement, triadic, square)

1 Like

I will support all effects that could be applied directly, so you will need to convert or you optionally could convert (depends on effect).

Your library will be really helpful, thanks!