PDA

View Full Version : Multicolor mouseover


Mint
09-06-2006, 11:24 PM
Hey all.

I'm sure some of you are familiar with the rainbow mouseover?
http://www.dynamicdrive.com/dynamicindex5/rainbow.htm

What I'm looking to do is change the code so it just changes between 2 or 3 colors, all of which go with my layout and won't be too distracting. The only thing is, in the actual .js file, I'm not sure what to edit or what to put in to change the colors. If anyone has done this, can you please help? Or, is there a better alternate?

Thanks.

RysChwith
09-07-2006, 08:23 AM
Well, the function you're going to need to modify is the makeColor() one (last one in the file). You'll probably end up just replacing the entire thing, but the important part is that it needs to return a string hex value (such as "#ff0000"). So you'll want to rewrite the function so that it selects one of your chosen colors, or a shade somewhere in between, and returns that.

Rys

Mint
09-07-2006, 11:48 PM
It actually goes by the Hue, Saturation and Value. I was always looking for a hex value, but that's what needs to be changed.

Thanks.

RysChwith
09-08-2006, 08:35 AM
It's making a conversion between the two. The important part is that that function returns a hex value as a string. You could dump all the HSV stuff, as long as that function continues to return the strings you expect, and has some way to increment them.

Off the top of my head, you could probably have it grab the current hex value of the link (maybe stored in a global variable?), break that into three two-digit pairs using parseInt() and substr(), then increment them and stuff them back in a string.

Rys