initial import
[roojs1] / Roo / lib / Beizer.js
1 /*
2  * Portions of this file are based on pieces of Yahoo User Interface Library
3  * Copyright (c) 2007, Yahoo! Inc. All rights reserved.
4  * YUI licensed under the BSD License:
5  * http://developer.yahoo.net/yui/license.txt
6  * <script type="text/javascript">
7  *
8  */
9 Roo.lib.Bezier = new function() {
10
11         this.getPosition = function(points, t) {
12             var n = points.length;
13             var tmp = [];
14
15             for (var i = 0; i < n; ++i) {
16                 tmp[i] = [points[i][0], points[i][1]];
17             }
18
19             for (var j = 1; j < n; ++j) {
20                 for (i = 0; i < n - j; ++i) {
21                     tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
22                     tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
23                 }
24             }
25
26             return [ tmp[0][0], tmp[0][1] ];
27
28         };
29     };