 -- If a chameleon's striking ability to change colors seems like a magic act of smoke and mirrors, that's because their skin is quite literally made up of special mirrors, scientists have discovered.

The panther chameleon has tiny crystals under its skin called iridophores that contract or expand when the animal is excited or feels threatened, a new study shows, explaining how the reptile can quickly shift between green, yellow and red.

Depending on the position of the reptile's skin, the crystals then reflect different levels of light that allow the animal to shift colors, according to a study published today in the journal "Nature Communications."

The crystals are arranged in a triangular lattice and are made from guanine, one of the building blocks of DNA, according to the study. Scientists used spectroscopy, the study of the interaction between matter and light, to observe changes in the skin of the reptile species that is native to Madagascar.

What they found was the ability of the chameleon to go from its natural camouflaged green color to red and yellow hues in a matter of two minutes thanks to the efficiently organized crystals. When the animal becomes excited, the crystal lattice stretches, allowing the iridophores to reflect different wavelengths of light.

"They are like selective mirrors," Michel Milinkovitch a co-author of the study at the University of Geneva in Switzerland told the BBC. "Light will bounce on them only for specific wavelengths. ... The other wavelengths will not bounce on these cells."