I'm still having trouble understanding why my random function produces colors with more gray in it though. From my understanding each of the components gets chosen randomly resulting in a random color.
What does "random" mean? This term doesn't make sense if not used together with a distribution. Usually, uniform distribution is assumed. But since color is a 3-dimensional space (not taking alpha into account), the easiest approach is to distribute each of the three components uniformly. This is what we do, and it results in a random color.
The fact that this color differs from your expectations is a different thing. Gray scale in RGB can be expressed as a vector (c, c, c), that is, all three components have the same value. If all three components have similar values, the color looks gray-ish. The more they differ, the more colorful (or saturated) the result tends to look.
However, the "colorfulness" cannot be easily expressed with RGB. That's why different color spaces exist, I already mentioned HSV (hue, saturation, value). They allow a representation which is more intuitive to human vision, but has to be converted for graphics hardware.
@Nexus: I am looking through the source of Thor's particle system to understand how it works and I have a question about the deletion of particles. I see that the deletion of dead particles happens in line 179. Which means that all dead particles are at the end of the vector. But new particles are also pushed to the end and I can't see any kind of swapping. Could you explain the magic that happens with writer?
The dead particles are removed from the vector by the call to the
erase() overload taking an iterator range:
mParticles.erase(writer, mParticles.end());
The reader/writer loop is basically an extended
std::remove_if() that both updates particles and moves the dead ones to the end, in order to avoid a needless second iteration.