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?
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.
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.
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.
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.
Business Card Ray Tracer
Jan 12, 2016
Back when I was in grad school I got inspired by Paul Heckbert’s business card ray tracer challenge and wrote my own version as a way to procrastinate from working on my thesis. A few years ago this was found by Fabien Sanglard who wrote a nice analysis of it which went viral for a bit. Recently, I was going through some old files and found the expanded version of it that I’d originally started with.
Converting Color Depth
Dec 19, 2015
Recently I wrote a program to perform image processing on a PNG image. Given that the input represented color in each channel with an unsigned byte and I wanted to process it as a floating point value in the 0.0 to 1.0 range, I wrote the code to divide by 255.0 on input and then multiply by 255.0 and truncate on output. This mostly works and seems to be the usual approach that people take. I’ve done it many times before but it’s always left me a bit uneasy. Is there a better way? I think there is.