<commit_before><commit_msg>Adapt mx.effects.easing or Tweener functions to be used for paths.<commit_after>//
// $Id: LinePath.as 359 2007-12-03 21:08:33Z dhoover $

package com.threerings.flash.path {

import flash.display.DisplayObject;

/**
 * Adapts mx.effects.easing or Tweener functions for use as a Path.
 */
public class EasingPath extends Path
{
    /**
     * @param destX the destination x coordinate
     * @param destY the destination y coordinate
     * @param duration the duration of the path, in milliseconds.
     * @param xfunc a Function to provide x coordinates. Signature: 
     *        function (t :Number, b :Number, c :Number, d :Number) :Number
     *        t = elapsed time
     *        b = initial position
     *        c = total change in position
     *        d = duration
     * @param yfunc a Function to provide y coordinates. If omitted, the xfunc is used.
     * @param startX the starting x coordinate. If omitted, the DisplayObject's current coordinate
     *        is used.
     * @param startY the starting y coordinate. If omitted, the DisplayObject's current coordinate
     *        is used.
     */
    public function EasingPath (
        target :DisplayObject, destX :Number, destY :Number, duration :int,
        xfunc :Function, yfunc :Function = null, startX :Number = NaN, startY :Number = NaN)
    {
        if (isNaN(startX)) {
            startX = target.x;
        }
        if (isNaN(startY)) {
            startY = target.y;
        }
        if (yfunc == null) {
            yfunc = xfunc;
        }
        _duration = duration;
        _startX = startX;
        _startY = startY;
        _deltaX = destX - startX;
        _deltaY = destY - startY;
        _xfunc = xfunc;
        _yfunc = yfunc;
        init(target);
    }

    override protected function tick (curStamp :int) :int
    {
        var t :Number = curStamp - _startStamp;
        _target.x = _xfunc(t, _startX, _deltaX, _duration);
        _target.y = _yfunc(t, _startY, _deltaY, _duration);

        // return the number of milliseconds before we're done
        return _duration - t;
    }

    protected var _xfunc :Function;
    protected var _yfunc :Function;
    protected var _startX :Number;
    protected var _startY :Number;
    protected var _deltaX :Number;
    protected var _deltaY :Number;
    protected var _duration :int;
}
}
{'fraction_non_alphanumeric': 0.08730493462673977, 'fraction_numerical': 0.007169970476592155, 'mean_word_length': 2.214092140921409, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6952125', 'n_tokens_mistral': 727, 'n_tokens_neox': 696, 'n_words': 243}