Was browsing through some conversations and there still seems to be confusion. So here is a copy paste (which someone probably already did ages ago) of the dev explanation:http://project-giana.com/forum/viewtopic.php?f=1&t=556&start=20The color of the gems doesn't matter for the final count. Only the amount does.
Master gems add 10 gems to your count, but don't affect your score otherwise.
The amount of gems you collect gives you up to three stars. The thresholds vary from level to level and are determined by us counting and subjectively determining trivial and nontrivial gems. Trivial gems are on the main path and mainly serve to show the way; they are easy to collect. Nontrivial gems either require some risk or skill to reach, or are hidden and require you to spot the hints. Note that trivial and nontrivial gems aren't flagged - they are simply gem amounts.
Collecting an amount of gems equal to 90% of the amount of trivial gems in a level awards one star.
Collecting an amount of gems equal to 100% of the amount of trivial gems plus 35% of the amount of nontrivial gems awards two stars.
Collecting an amount of gems equal to 100% of the amount of trivial gems plus 70% of the amount of nontrivial gems awards three stars.
Depending on gem quantity and distribution, this roughly requires you to collect between 20% and 55% of the total gems in a level for one star, between 50% and 75% of the gems for two stars, and between 75% and 90% of the gems for three stars. Basically, the easier the gems are to collect in a level, the more you need to collect for a higher rating.
Keeping your death count low awards up to two stars.
If you die between 6 and 20 times, you get one star.
If you die between 0 and 5 times, you get two stars.
Dying does not affect the amount of stars you gain for collecting gems.
You need an average of 3 stars per non-boss level to unlock a boss level. This does not carry over between worlds.
You don't need to reach three stars in each level. If you five-star a level, you can one-star another.
This average will be lowered to 2.5 stars per level (rounded down) in the next patch so that you don't need to collect gems like crazy if you die a lot.
Purple stars are awarded in boss levels. They serve to unlock hardcore mode and don't influence the star count in the next world.
The thresholds are a little more generous since the last patch (e.g. it used to be up to 3 and 10 deaths instead of 5 and 20), so you may have observed different results if you experimented before the patch.
These chanegs went live in the november patch