DEV Community

Cover image for A pet project: sorting colors
Thomas C. Haflich
Thomas C. Haflich

Posted on

A pet project: sorting colors

Cover photo by Ana Cruz via unsplash.

I was told to talk about my pet projects:

So here goes nothing...

Sorting colors! It can't be done--well, not perfectly. Colors are represented in a 3d space, and the type of sort here is represented linearly, and that's just not going to look quite right no matter how you slice it.

A cube made of colorful other cubes, representing the RGB color space. RGB Colorspace representation, sourced from Wikipedia

A cylinder representing the HSV colorspace, with a slice removed to show the inside. HSV Colorspace representation, sourced again from Wikipedia

A bicone representing the Hue/Chroma/Lightness model of color. This is getting wacky. What even is colors? How can colors be real if our eyes aren't even real?

The question I want to ask is: Which way is least bad?

A screenshot of my color sorting project. It does not look very good. If you are visually impaired, and that's why you're getting this text, you aren't missing much.

It's great, because literally nobody cares about this but me. I can nerd out about color all I like.

So far in setting this up, I've learned a lot about modern build methods and how much I don't care to use them on a project spanning approximately a dozen files. They add an awful lot of work and restriction to the stack and setup of a project, and it ended up not being worth it for what ended up being two lines of code in a shell file run from Atom.

I also am putting an arbitrary constraint on myself to see if I can finish it without including any dependencies as packages. We all joke about node_modules, right? At time of writing, the external loads are a font and jQuery (I know, I know, it's date('Y'), shh), and other than that it's just sass and minify installed globally. I'd like to challenge myself to keep this lean.

I also refreshed myself on ye olde jQuery. It's been awhile. Like meeting an old friend again. It's changed a bit since I last saw it!

It's not done yet, but if you happen to want to take a look at this while its guts are still all over the floor, here it is:

https://tchaflich.github.io/color-sorts/

GitHub logo tchaflich / color-sorts

Finding ways to sort colors

color-sorts

Finding ways to sort colors




Discussion (0)