2 * Copyright (C) 2016 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17//====================================\\
18// 13thParallel.org BeziƩr Curve Code \\
19// by Dan Pupius (www.pupius.net) \\
20//====================================\\
23var coord = function (x,y) {
29function B4(t) { return t*t*t }
30function B3(t) { return 3*t*t*(1-t) }
31function B2(t) { return 3*t*(1-t)*(1-t) }
32function B1(t) { return (1-t)*(1-t)*(1-t) }
34var getBezier = function(percent,C1,C2,C3,C4) {
35 var pos = new coord();
36 pos.x = C1.x*B1(percent) + C2.x*B2(percent) + C3.x*B3(percent) + C4.x*B4(percent);
37 pos.y = C1.y*B1(percent) + C2.y*B2(percent) + C3.y*B3(percent) + C4.y*B4(percent);