Well, I found a summary of how fireworks work. It doesn’t really explain some of the more interesting patterns; it just describes the basics. The firework shell uses black powder (gunpowder) at its base to launch it; when this lights, it ignites a fuse that delays the explosion long enough for the shell to reach the right height. The fuse ignites another powder that explodes the shell, lighting the components that actually produce the visual effect and pushing them outward away from the shell.
Those components (another site calls them ‘stars’) burn from the outside in. It should be pretty obvious, but what they’re composed of determines the color they burn. Various metal salts are used to produce the visual effects. About.com has a nice page with info on what the different elements used do.
I already knew that magnesium burns white (cheers to high school chem class for letting us test this empirically!); so does iron, if it’s hot enough (iron burns red, otherwise), as well as aluminum and titanium. All four of these create sparks, so mostly they’ll be the ones that create the crackling sparkler look in some fireworks. Antimony is used for glitter (shimmer?).
Lithium and strontium can also be used for red light; orange is calcium; green is barium; yellow is likely sodium. Copper burns blue, which I find interesting – in glazes for pottery, copper can create either green or red color, depending on whether it was oxidized or reduction-fired (the difference being abundance or lack of oxygen for the fire). We burned copper in chemistry class, too, but I don’t remember what it looked like. Quite the colorful element.
As far as the different patterns and color changes, I guess that would just depend on how the ‘stars’ are packed into the shell. Coat one metal salt with one that makes a different color, and the light will change color when the outer layer has burned through. Pack ‘stars’ with more ‘stars’, and perhaps that gives you a secondary explosion – just as the first burst fades, the blast powder inside the ‘stars’ ignites, lighting the second round of ‘stars.’ Or similar for the rocket launcher firework.