2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
8 YUI.add('anim-curve', function (Y, NAME) {
11 * Adds support for the <code>curve</code> property for the <code>to</code>
12 * attribute. A curve is zero or more control points and an end point.
14 * @submodule anim-curve
17 Y.Anim.behaviors.curve = {
18 set: function(anim, att, from, to, elapsed, duration, fn) {
19 from = from.slice.call(from);
20 to = to.slice.call(to);
21 var t = fn(elapsed, 0, 100, duration) / 100;
23 anim._node.setXY(Y.Anim.getBezier(to, t));
27 return anim._node.getXY();
32 * Get the current position of the animated element based on t.
33 * Each point is an array of "x" and "y" values (0 = x, 1 = y)
34 * At least 2 points are required (start and end).
35 * First point is start. Last point is end.
36 * Additional control points are optional.
40 * @param {Array} points An array containing Bezier points
41 * @param {Number} t A number between 0 and 1 which is the basis for determining current position
42 * @return {Array} An array containing int x and y member data
44 Y.Anim.getBezier = function(points, t) {
45 var n = points.length,
50 for (i = 0; i < n; ++i){
51 tmp[i] = [points[i][0], points[i][1]]; // save input
54 for (j = 1; j < n; ++j) {
55 for (i = 0; i < n - j; ++i) {
56 tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
57 tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
61 return [ tmp[0][0], tmp[0][1] ];
66 }, '3.13.0', {"requires": ["anim-xy"]});