View full size
Fire from a grid of numbers
The window has the controls on the left and the fire on the right. The fire is a grid of temperatures from 0 to 255. Each frame lights random sparks on the bottom row and cools others, then every cell takes the average of itself and the three cells below, with a little noise and a cooling constant. A palette of 256 precomputed colours turns each temperature into a pixel. The exercise also set the architecture: the view and the model only talk through the presenter, and the model updates the fire about 30 times per second on its own thread, drawing into a back buffer so a half-painted frame never reaches the screen. Stop doesn't cut the fire: it dies out over two seconds.