[thelist] Javascript (Math Skills Needed)

Christian Heilmann codepo8 at gmail.com
Wed Aug 8 12:31:04 CDT 2007


> > It appears you simply call the fader() function with the final values
> > you want, so
> >
> > fader(element,243,244,255)
> >
>
> That is incorrect.
>
> The RGB value you put in fader(element,R,G,B) is the color you want to
> show up, which will then always fade to white.

You'd need to modify the if (red == 255 && green == 255 && blue ==
255) { to your values, however, the issue is that the fader goes in
steps of 10 so it may never reach your values.Therefore you need to
use

if (red >= 243 && green >= 244 && blue >= 255)

The Math is actually really easy, the only thing that might not be
explained well is Math.ceil() which returns the next integer.
Math.ceil(3.6) is for example 4

The other bit dirty bit about the function is that it just returns
when the final colour is reached.

HTH
Chris

-- 
Chris Heilmann
Book: http://www.beginningjavascript.com
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/



More information about the thelist mailing list