Leopards' spots and tigers' stripes are a camouflage closely tied to their habitats, researchers say.
A UK team examined the flank markings of 37 species of wild cats in a bid to understand the spectacular variety of their colour patterns.
The scientists say that cats living in the trees and active at low light levels are the most likely to have complex and irregular patterns.
They published the findings in a Royal Society journal.
It is not the first study to suggest that wild cats need spots to "vanish" in dense forests, sandy deserts or snowy mountains.
But this time, the researchers analysed the colour patterns' detailed shapes and complexities, stating that these two factors are vital for camouflage.
To examine different patterns, the team used images obtained from the internet and classified them with the help of mathematical formulas.
"[Some species] are particularly irregularly and complexly spotted," William Allen from the University of Bristol, the lead author of the study, told BBC News.
"The pattern depends on the habitat and also on how the species uses its habitat - if it uses it at night time or if it lives in the trees rather than on the ground, the pattern is especially irregularly spotted or complexly spotted."
The first part of the study's title, as it appears in the journal Proceedings of the Royal Society B is "Why the leopard got its spots".
Dr Allen said that the title has been inspired by a short story of Rudyard Kipling with a similar name, "How the leopard got his spots".
In the story, an Ethiopian first changed his skin colour to black and then "put his five fingers close together (there was plenty of black left on his new skin still) and pressed them all over the Leopard, and wherever the five fingers touched they left five little black marks, all close together. Sometimes the fingers slipped and the marks got a little blurred; but if you look closely at any Leopard now you will see that there are always five spots - off five black finger-tips".
Dr Allen explained that though the fingertips idea was understandably fictitious, Mr Kipling's deduction about leopards needing spotty coats to "disappear" among trees was spot on.
"The mechanism - the fingerprint - isn't the right idea, but it is actually the case that leopard's spots and similar patterns evolve in forest habitats," said the scientist.
Dr Allen's study still fails to explain the mechanism of wild cats' pattern development - but the scientists managed to find a set of numbers to measure the irregularity or complexity of a pattern and correlate this with where the species lives to explain its behaviour.
"We've shown that the usefulness of patterns for species' survival can be related to a mathematical model of how the pattern arises and what that does is it gives more complex information on why the leopard has its spots," said Dr Allen.
And it is all about genetics, he added.
"When you place cat patterning over the evolutionary tree of cats, you can see that patterning emerges and disappears very frequently within the cat family, which is kind of interesting - it suggests that perhaps particular genetic mechanisms can solve very different appearances of cats."
Previously, researchers believed that wild cats used their colour patterns to attract members of the opposite sex, but Dr Allen's team discounted this theory, saying that if there were a sexual motive, "you'd expect to see different patterns in males and females, which you don't".
"Another idea is that the patterns might have some sort of social signalling function, but again we didn't support this because the type of pattern cats have isn't related to their social system.
"For example, lions don't have particular flank markings that help them get along with living in prides."