Forum » Ajax Animator » Contribution

colors interpolation

(4 posts)

Tags:

  1. josep_ssv
    Member

    http://aamap.110mb.com/animator/op_view/colors3.htm
    http://aamap.110mb.com/animator/op_view/player_files/tween_core.js
    //in Ax.tweenAttribute


    if (name == "fillColor") {
    return Ax.tweenHex(frame1, frame2, value1, value2, index);
    }

    ///////////////


    Ax.tweenHex = function(frame1, frame2, value1, value2, index){//frame1, frame2, first number, second number, index (from first)
    value1dec=hex2rgb(value1);
    value2dec=hex2rgb(value2);

    var r=Ax.tweenNumber(frame1, frame2, parseInt(value1dec.R), parseInt(value2dec.R), index);
    var g=Ax.tweenNumber(frame1, frame2, parseInt(value1dec.G), parseInt(value2dec.G), index);
    var b=Ax.tweenNumber(frame1, frame2, parseInt(value1dec.B), parseInt(value2dec.B), index);

    return '#'+toHex(r)+''+toHex(g)+''+toHex(b); //just hope this works!
    }

    //////////////////
    //COLOR FUNCTIONS
    //////////////////
    function hex2rgb(hex)
    {
    var regexp = new RegExp('^#?([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$');
    var match = hex.toLowerCase().match(regexp);
    if (match)
    {
    return {R:parseInt(match[1], 16), G:parseInt(match[2], 16), B:parseInt(match[3], 16)};
    }
    else
    {
    return(null);
    }
    }

    function toHex(color)
    {
    color=parseInt(color).toString(16);
    return color.length<2?"0"+color:color;
    }

    Posted 1 year ago #
  2. josep_ssv
    Member

  3. admin
    Key Master

    Cool! I'm adding it now!

    Posted 1 year ago #
  4. admin
    Key Master

    Ok. I added the feature.

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.