Search code examples
javascriptmootools

Mootools color instant morphing


what I'm searching is an fast way to instantly morph colors - (not by event / time). It would be nice if there is any function like morphColors(color1,color2,percent) - percent should give in a fractional value that says how much the morphing should go.

Maybe there is also a Javascript way?

Thx in advance!


Solution

  • you could use Fx class to do stuff but it's not % based.

    mootools also has an official plugin in more: http://mootools.net/docs/more/Utilities/Color - see .mix()

    have a read of lessc's source here for ideas - https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js#L159-L177 - colour mix 2 colours with a weight.