Printing Floating-Point Numbers

March 05, 2014

Dragon CurveAs far as I could find (as of today - March 5, 2014), there are only two open source implementations of floating-point to string conversion that are efficient, accurate and output "pretty" results. The code can be hard to follow and the licenses are a little more restrictive than I prefer. As an everyday tool that is often taken for granted, it might be surprising that it is so rarely implemented, but it's actually nontrivial to solve. It's also one of those problems complex enough where a wise engineer might recommend that "you never write your own", but I like a challenge and have been interested in it for a while. After spending a couple weeks investigating and experimenting, hopefully I can make it a bit more digestible for the curious.

RJ 9-bit

January 7, 2014

RJ 9-bitI made this font for my updated site design. Every character is made from a 3x3 grid and it supports the basic latin character set (but the punctuation is a bit of a mess to be honest).


Feel free to download and use it as long as you give me credit. It's released under the Creative Commons Attribution 4.0 International License.

Damped Springs

July 20, 2012


I've worked on third-person camera systems for numerous games and I often need a method for smoothing camera motion as the player moves through the world. The player’s motion may create sharp, discontinuous changes in direction, speed or even position. The camera, however, should:

  1. Avoid discontinuities in motion. Accelerate and decelerate as needed rather than snap to a new velocity.
  2. Never let the player outrun the camera. The farther away he gets, the faster the camera needs to move.
  3. Move exactly the same with respect to time regardless of frame rate.


To solve this problem, I often simulate the camera with a set of damped springs.


How to use ASSetPropFlags in ActionScript 2.0

August 28, 2010

There are multiple undocumented functions in ActionScript 2.0 of which one is ASSetPropFlags. I needed to use this function on a project recently and quickly found out that most of the unofficial documentation is either incorrect or overly brief. What I'm going to do here is describe how the function works and then show a program that will test and confirm some of the more complex functionality. 

RGB Color Space Conversion

May 16, 2010

titleI've been on a bit of a color science kick lately and transferring from one color space to another becomes a common operation when you want to properly play with digital color values. Normally we just think of digital colors as RGB values, but there are many ways to numerically describe a color. Just opening PhotoShop's color picker lets you choose colors as HSV, Lab, or CMYK values in addition to the standard RGB. If you're a bit more adept with PhotoShop, you've may have even ventured into the Color Settings which has even more options including which version of RGB that your image will use. It is this concept of multiple RGB spaces that I'm going to focus on. 


Depending on how you ended up here, it might even be a surprise that there are multiple types of RGB, so I'll do my best to present some background on that and introduce a color space called XYZ. Then we can walk through the math for converting between all these RGB variants and discuss why you would even consider doing so. Finally, I'll present some example code for implementing the color space conversion.