z3bra, the stripes apart

Vomiting colors

— 09 June, 2015

Creating colorschemes is one of the hardest part of customizing your desktop. The easiest way to create a new one is to start from a wallpaper made of colors you like, and then rework it afterward.

the best tool for this job is without any doubt colors by sin. It uses k-means clustering to extract dominant colors from a PNG file, and is able to set those clusters in different ways.

Without any further commenting, let's see how it works with this magnificent picture, randomly taken from the internet:


colors allow you to choose the number of clusters you want to see on the output, so in our case, we'll output 16. It's possible that colors don't output the number of clusters you asked for. You can "force" outputing empty clusters with -e.

default output

Then you can choose how to set your clusters (from the hue domain or pixel space at the time of writing). Another solution when you don't get the number of colors you asked for (in my case, I only got 12 colors with -h), is to just ask for more, and truncate the output. It might give better colors than with -e sometimes.

output from hue output from pix

And then you can randomize the output, if you feel in the mood! You could also try using the k-medians method, which takes longer but provides a better output regarding the initial file

output random

Try different pictures and flag combinations for better results!

Once you have your output of choice, you can export it as an XRDB colorscheme with the following script:


while read HEXCODE; do
    printf '*color%d: %s\n' "$CPT" "$HEXCODE"
    CPT=$(expr $CPT + 1)
done | column -t

This will allow live theme trying with the following command:

colors -n 16 bamboo.png | toxrdb | xrdb -merge

Another nice way I found to create colorscheme is by randomizing the colors from the hue domain, resulting in a monochromatic scheme that fits entirely you wallpaper. This works by outputing 32 colors, extracting the 16 colors in the middle and randomizing them. this way, your colors will not be too dark or too light.

output neat

You can then make a script to change your wall every now and then, and change the colorscheme on the fly. Your colorscheme will ALWAYS match your current mood!

Keep tweaking!