[Tutor] reassign
Alan Gauld
alan.gauld at btinternet.com
Sat Apr 14 14:40:17 CEST 2007
"linda.s" <samrobertsmith at gmail.com> wrote
>I wonder how to use colors from gray to black to represent a group of
> values from small to large?
Can you explain what you mean? Normally colours are represented
in code as a tuple of three numbers for the RGB values. If its shades
of grey then all three numbers are the same so you only need a
single number.
But you don't store colours in a program (except maybe as
string representations, eg 'cyan', 'blue', 'azure'). I'm not sure what
you mean by using colours to represent values. Usually its the other
way around?
If you do mean turning a range of values into shades of grey then
thats faitrly easy, just scale your values between 0 and 255,
where black is (0,0,0) and white is (255,255,255). If you have
N values then the scaling factor is 255/N. Then simply multiply
the value by the factor...
Alan G.
More information about the Tutor
mailing list