There are four basic colors in fall leaves and a different pigment produces each. Xanothophylls is responsible for yellow, carotenoids for orange, tannin for brown and anthocyanids create the red and purple tones.
During the growing season green chlorophyll in tree leaves is broken down by sunlight and constantly replenished. As day length decreases the abscission cells, a special layer at the leaf-stem junction, divide rapidly and slowly block transport of materials. As abscission begins, a chlorophyll production wanes and eventually stops.
As the green chlorophyll breaks down without replacement we begin to see the underlying orange carotenoids and yellow xanthophylls. These pigments help capture light energy during the growing season. But unlike yellow and orange pigments, red anthocyanins are made during fall leaf senescence. It is manufactured from sugars found in the leaf. They produce greater amounts during cooler nights and sunny days. When a hard freeze comes along, production ends.
Why would a tree use energy to make a pigment in a leaf that is about to die and fall off? In 2003 William Hoch, a biologist at Montana State University, found that if he genetically blocked anthocyanin production, the leaves were much more vulnerable to fall sunlight damage, and so sent less nutrients to the plant roots for winter storage before the leaf fell. The tree was not able to recuperate as much energy back from the leaves it grew earlier in the year.
A few years later, University of North Carolina at Charlotte graduate student Emily Habinck found that in places where the soil was lower in nitrogen and other important elements, red maple trees produced more anthocyanin in the leaves. Apparently trees growing in more stressful environments invest in more anthocyanin, which allow them to recover more nutrients that are stored in the leaves before they fall.