There are plenty of libraries out there for Actionscript and Javascript to tween or fade between colors, but when building our own applications I have always come across use cases for having the ability to generate the hex value that is at a certain percentage or ratio between two hex values (fade between hex values). A simple implementation of this is generating a gradient between two colors.
Sample Code
RightSignature
6 Comments
Wow, that really is amazing! Compact too!
If you don’t mind, I would like to use this in my InterModule javascript library (
http://intermodule.sf.net/
)
Thanks for the great idea!
That would be awesome!
I’m having a little trouble coding the function into my library. Can you reply with more detached code (less integrated to the specific instance)? Like, help me write the function that you input two and “returns” the array of blends?
That would be great.
Never fret; as I have figured it out. When you see InterModule 1.9.06, you will see your nice blend function as im.Color()[.blend()] – meaning the new color API object will have a blend function to blend with another color object at a certain percentage.
Cheers, delan :p
Kinda buggy. Try 0×0000FF and 0×00FF00 with 100 divisions or 0×0000FF and 0×000F00 with 100 divisions
perfect!