|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.default = void 0;
|
|---|
| 7 | var _basis = require("./basis.js");
|
|---|
| 8 | function Bundle(context, beta) {
|
|---|
| 9 | this._basis = new _basis.Basis(context);
|
|---|
| 10 | this._beta = beta;
|
|---|
| 11 | }
|
|---|
| 12 | Bundle.prototype = {
|
|---|
| 13 | lineStart: function () {
|
|---|
| 14 | this._x = [];
|
|---|
| 15 | this._y = [];
|
|---|
| 16 | this._basis.lineStart();
|
|---|
| 17 | },
|
|---|
| 18 | lineEnd: function () {
|
|---|
| 19 | var x = this._x,
|
|---|
| 20 | y = this._y,
|
|---|
| 21 | j = x.length - 1;
|
|---|
| 22 | if (j > 0) {
|
|---|
| 23 | var x0 = x[0],
|
|---|
| 24 | y0 = y[0],
|
|---|
| 25 | dx = x[j] - x0,
|
|---|
| 26 | dy = y[j] - y0,
|
|---|
| 27 | i = -1,
|
|---|
| 28 | t;
|
|---|
| 29 | while (++i <= j) {
|
|---|
| 30 | t = i / j;
|
|---|
| 31 | this._basis.point(this._beta * x[i] + (1 - this._beta) * (x0 + t * dx), this._beta * y[i] + (1 - this._beta) * (y0 + t * dy));
|
|---|
| 32 | }
|
|---|
| 33 | }
|
|---|
| 34 | this._x = this._y = null;
|
|---|
| 35 | this._basis.lineEnd();
|
|---|
| 36 | },
|
|---|
| 37 | point: function (x, y) {
|
|---|
| 38 | this._x.push(+x);
|
|---|
| 39 | this._y.push(+y);
|
|---|
| 40 | }
|
|---|
| 41 | };
|
|---|
| 42 | var _default = exports.default = function custom(beta) {
|
|---|
| 43 | function bundle(context) {
|
|---|
| 44 | return beta === 1 ? new _basis.Basis(context) : new Bundle(context, beta);
|
|---|
| 45 | }
|
|---|
| 46 | bundle.beta = function (beta) {
|
|---|
| 47 | return custom(+beta);
|
|---|
| 48 | };
|
|---|
| 49 | return bundle;
|
|---|
| 50 | }(0.85); |
|---|
Note:
See
TracBrowser
for help on using the repository browser.