An artist’s rendering shows the Sinosauropteryx dinosaur in the open habitat where it probably lived 130 million years ago. Robert Nicholls/University of Bristol

Scientists have managed to figure out the color patterns of a dinosaur that once lived in China and those patterns, which made it look like a cartoon bankrobber, shows it used tricks of light to camouflage itself and stay hidden from predators.

After finding traces of pigment in the fossil of a feathered dinosaur called Sinosauropteryx, a team of scientists reconstructed the colors of the creature and analyzed the patterns they found there, according to a study in the journal Current Biology. The 130-million-year-old theropod had what they described as a “bandit mask” — a dark band across its eyes reminiscent of what you may see on a raccoon and some birds.

The dinosaur also showed countershading patterns, in which the top part of the animal is darker-colored and the bottom is lighter. This offsets the light shining down from the sun, potentially interfering with another animal’s depth perception and thus disguising the target.

The camouflage may have helped it stay hidden from both carnivorous predators and from its own prey.

“Far from all being the lumbering prehistoric gray beasts of past children’s books, at least some dinosaurs showed sophisticated color patterns to hide from and confuse predators, just like today’s animals,” researcher Fiann Smithwick said in a statement from the University of Bristol. “Vision was likely very important in dinosaurs, just like today’s birds, and so it is not surprising that they evolved elaborate color patterns.”

But the exact color patterns do more than tell the researchers that Sinosauropteryx used camouflage. According to the study, they also indicate the type of environment in which the dinosaur lived during the early Cretaceous period.

The experts explained in a video that the dinosaur’s stark transition from its dark topside to its light belly tells them that it lived in an open habitat where light was coming down from above unimpeded.

Animals that live in more forested areas, for example, will show a more gradual change from their dark side to their light side.

“Our results show how reconstructing the color of extinct animals can inform on their ecologies beyond what may be obvious from skeletal remains alone,” the study says.

The likely habitat of Sinosauropteryx further tells scientists about the layout of prehistoric Earth. According to the study, the Jehol Biota site in Liaoning, China, where the theropod lived has been believed to be primarily forest, but its camouflage type suggests there may have been more variety in that environment.

“By reconstructing the colour of these long-extinct dinosaurs, we have gained a better understanding of not only how they behaved and possible predator-prey dynamics, but also the environments in which they lived,” Smithwick said. “This highlights how paleocolor reconstructions can tell us things not possible from looking at just the bones of these animals.”

Experts have only recently been able to pull color out of these old fossils. Just last month, a team of researchers suggested that a certain species of oviraptors from Mongolia and China built open nests for their eggs instead of burying them, based on the likely coloration of the eggs. The researchers found remnants of two pigments in fossilized eggshells that are common in bird eggshells today and produce a blue-green hue. Modern birds use colored eggs to camouflage them or divert attention away from them, so predators don’t attack their nests; birds that produce white eggs don’t need pigment because they constantly brood over and protect their unborn. The same could have been true for the ancestors of these birds, the dinosaurs.

According to those researchers, the egg coloration also fills gaps in evolutionary information, because it speaks to when this trait emerged.

An early Cretaceous period fossil of Sinosauropteryx, shown next to an interpretive drawing of its remains. University of Bristol