The fire effect is a classic. The way it works is with an array of color indices into a palette. The palette is arranged so that it fades from black at the bottom of the palette, to orangish red in the higher indices. On each frame, the array is traversed and each pixel is averaged with adjacent pixels. It is then darkened slighly so that the pixels on higher rows are darker than the ones below it. The bottom row (just offscreen) is filled with random indices. This becomes the fuel of the fire effect.

Because the fire is darkened by a constant value, the fire is limited vertically. The classic fire effect is optimized for 55 pixels high. I do the same here, using the canvas to scale the output.

You can view the source here.