# [thelist] Javascript (Math Skills Needed)

liorean liorean at gmail.com
Wed Aug 8 13:04:08 CDT 2007

```Actually, as long as you don't want to do a fade over a grey scale,
you need to determine the stepping for each of the colours separately.

First of all, decide on a time consumption and a frequency for the
changes. (If you update the display too often som browsers may skip
drawing each step. If you update too slow, the switches become too
apparent for the human eye.)

Then you calculate the difference between the initial value and the
final value for each colour separately. (There's other ways to fade

For each colour, divide the colour change by the number of steps.
Round the value down and store as step size for that colour. Then you
save the remainder of the change divided by the step size as the size
of the final step.

Make a counter, do the changes to all three colours one step at a
time, until the counter reaches zero. Then you do the final step.

That should do it, unless I've missed something needed for the fade.
--