As autumn rolls in, the beach-going tourist dons his toasty sweater and becomes the leaf-peeping tourist. What the foliage enthusiast might not fully appreciate, however, is how the splendid fall colors on display are a botanical swan song - a colorful last hurrah from leaves whose days are numbered.

Temperature plays a role in how the leaves turn, but the increasing chill of fall is only part of the story. The mechanism behind the colors of autumn leaves is the process by which a tree prepares to drop its leaves, which are metabolically costly to maintain. In the light-poor season of winter, a leaf's solar-collecting power doesn't justify the expense.

Deciduous (leaf-shedding) trees like oaks and maples can sense the changing of the seasons through the shift towards shorter days. Once nights reach a certain length, a change occurs in the cells where a tree's leaves join their stems. These cells start to divide, forming the bottom part of what's called the abscission layer, the seam where the leaf eventually falls off from.

As the cells in the abscission layer become drier and more cork-like, it creates a barrier to the transport of minerals and other substances into the leaf. The green pigment chlorophyll breaks down in sunlight, and with no fresh supply coming from the rest of the plant, the leaf soon runs out.

However, chlorophyll is not the only pigment in leaves. When the green veil is pulled off, other colors are revealed: orange, from carotenoid pigments and yellow, from another class of carotenoid pigment called xanthophylls.

Some fall foliage is colored red or purple from other kinds of pigments called anthocyanins. Anthocyanins, however, are usually not present in the leaf throughout the summer. They're made in the fall, out of the remaining bits of sugar in the doomed leaf. It's still not completely clear why a tree would spend resources on an organ that's about to be discarded, but some botanists think it may be a way to ward off aphids and other insects that are attracted to the color yellow.

Whether to put on a red or yellow display is a choice that trees must weigh carefully, according to crop researcher Thomas Doring.

"If insect attack is generally high, causing higher costs than the costs for the production of red anthocyanins in autumn, trees would benefit from being red. If the costs entailed by the insects is lower, than you can afford to stay yellow," Doring told The Telegraph in 2008.

Eventually, xanthophylls and anthocyanins follow chlorophyll into oblivion, breaking down and leaving behind the hardy brown tannins.

The timing and quality of a Technicolor autumn leaf display also depends on environmental factors like soil moisture, sunlight and temperature. More sun and colder weather can destroy chlorophyll quicker and encourage anthocyanins to form. Frost halts production of red pigments, while drought in spring and summer may mean leaves drop before they can become colorful.

The best conditions to slake a leaf-peeper's desire, according to the U.S. National Arboretum, are a rainy spring and summer followed up by a bright, cool and dry autumn.

Each year, leaf turnings are subject to the whims of weather. Last year's autumn display in the Northeast US was cut short by an intense snowstorm at the end of October. But despite that record-breaking snowfall, it was still a fairly dry and warm winter. The dry and early spring could spell early yet vibrant fall foliage, but only if the first few weeks of autumn are relatively mild.

"The trees in New England have been through some rather unprecedented events in the past year, and it is therefore difficult to predict the strength of the overall colors, but conditions could be favorable for the development of red pigments this autumn," meteorologist Jim Salge wrote for Yankee Magazine in August. "Otherwise, it may just shape out to be an average color year that emerges a bit early."