Color Palette Math

I spent some time today fiddling around with simplifying a few popular 16 color palettes because of an Adventuron text color limitation. While there are no color palette limitations on any graphics files you import, Adventuron only supports 3 character hex codes when setting text colors. That translates to only 4096 possible colors which should be perfectly adequate for most uses, but makes matching an arbitrary limited color palette a little bit tricky. I was curious to see how close a given palette would look to the original if I simplified it down to three character hex codes by rounding to the closet value. So I did a little math, figured out that 3 color hex values translate to a 17 number gap in decimal and used that knowledge to start rounding up or down.

The first 16 color palette I tried this on was Dawnbringer 16. The upper half of each color is the adjusted value, while the bottom half is still the original shade for comparison.
I ended up tweaking the hex values on the fourth color from 545 to 444 because I felt the rounded result was a little too purple compared to the original, but otherwise I stuck with rounded values.

The second palette I tried was Pico-8 and I have to say it translated quite nicely. The visible differences are all still quite subtle and there weren't any I manually tweaked.

Overall I'd say they're definitely close enough to pass muster. I don't think I would bother to convert existing images to the aligned palettes, instead I would just use the values for the text that I wanted to match knowing that it should be close enough and not really discernible.