Andrew Kensler
About Archive Topics Feed

Andrew Kensler’s Blog

A Tour of the Tiny and Obfuscated Image Decoder

Sep 14, 2020

I was mystified when I first came across the “Most Inflationary” winning entry in the 2018 IOCCC. Written by the incredibly prolific Fabrice Bellard, this tiny program with just 4KB of source code emitted a 128×128 resolution version of the (in)famous Lena test image. Voodoo! The IOCCC judges wrote “We could understand some of the arithmetic but none of the magic.” I was determined to figure out the magic and inspired by Fabien Sanglard to try to write up how it works.

Read more…

More on Palettes

Aug 10, 2020

I was recently asked a pair of questions regarding palettes and my previous posts on them. First, I was asked about what a 48-color palette generated by my palette generator algorithm would look like. Secondly, a different person asked me what my mapping approach would make of the extended Pico-8 palette with the 16 additional colors that have been added.

Read more…

Circles In Angles

Dec 27, 2018

Suppose that we have the 2D coordinates for three three ordered, non-colinear points that together define an angle. We also have the radius for a circle inscribed in the angle. How can we efficiently calculate the coordinates where the center of the inscribed circle must be?

Read more…

Blending for Dithering

Sep 23, 2017

What’s the correct color space to compute color blends in for dithering for display on a typical monitor? At one point in my palette experiments I had written some dithering code and naively assumed CIELAB since that’s designed to be perceptually uniform. But I had noticed that I was getting some odd color casts. Initially I’d thought I’d had a bug, but I eventually realized that it was because CIELAB is the wrong color space. Linearized RGB with sRGB primaries is the way to go. Here’s why.

Read more…

A 54-Color Palette

Sep 19, 2016

I recently received an e-mail asking if I could run my palette generator to produce a 54-color palette. This is the same number of colors available on the old NES console (though it couldn’t do them all it once) and the person was curious how a palette from my program would compare. I’d always figured that if I ran my program again for a larger palette it would be for either 48 or 64 colors. But sure, I can do 54. Here’s what my program came up with.

Read more…

Mapping Pixel Art Palettes

May 27, 2016

While researching pixel art palettes, one of the things I noticed was a lot of discussion about color ramps. As I read it, these are essentially subsets of the colors in the palette that form distinct gradients and they are most commonly shown laid out on a grid interlocking with each other like a crossword puzzle. This seemed like a nice, qualitative way to assess a palette and got me wondering how to map out a palette automatically. I think I’ve come up with an interesting alternative to these crossword-style layouts.

Read more…

Pixel Art Palettes for Free

May 6, 2016

Ever since I discovered DawnBringer’s 16-color and 32-color palettes and later Arne’s, I’ve been thinking about what makes a good small but general-purpose palette (DawnBringer’s palettes are pretty neat, but they’re a bit desaturated and lacking in purples for my taste – you couldn’t do Monkey Island with them). So far as I know, their palettes were carefully selected by hand. But I write code, so I took it as a challenge to see if I could create a short program that would automatically generate good palettes from scratch. Here are the results of my experimentation.

Read more…