source: node_modules/victory-vendor/lib-vendor/d3-shape/src/curve/catmullRomClosed.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 2.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7var _cardinalClosed = require("./cardinalClosed.js");
8var _noop = _interopRequireDefault(require("../noop.js"));
9var _catmullRom = require("./catmullRom.js");
10function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11function CatmullRomClosed(context, alpha) {
12 this._context = context;
13 this._alpha = alpha;
14}
15CatmullRomClosed.prototype = {
16 areaStart: _noop.default,
17 areaEnd: _noop.default,
18 lineStart: function () {
19 this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
20 this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
21 },
22 lineEnd: function () {
23 switch (this._point) {
24 case 1:
25 {
26 this._context.moveTo(this._x3, this._y3);
27 this._context.closePath();
28 break;
29 }
30 case 2:
31 {
32 this._context.lineTo(this._x3, this._y3);
33 this._context.closePath();
34 break;
35 }
36 case 3:
37 {
38 this.point(this._x3, this._y3);
39 this.point(this._x4, this._y4);
40 this.point(this._x5, this._y5);
41 break;
42 }
43 }
44 },
45 point: function (x, y) {
46 x = +x, y = +y;
47 if (this._point) {
48 var x23 = this._x2 - x,
49 y23 = this._y2 - y;
50 this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
51 }
52 switch (this._point) {
53 case 0:
54 this._point = 1;
55 this._x3 = x, this._y3 = y;
56 break;
57 case 1:
58 this._point = 2;
59 this._context.moveTo(this._x4 = x, this._y4 = y);
60 break;
61 case 2:
62 this._point = 3;
63 this._x5 = x, this._y5 = y;
64 break;
65 default:
66 (0, _catmullRom.point)(this, x, y);
67 break;
68 }
69 this._l01_a = this._l12_a, this._l12_a = this._l23_a;
70 this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
71 this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
72 this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
73 }
74};
75var _default = exports.default = function custom(alpha) {
76 function catmullRom(context) {
77 return alpha ? new CatmullRomClosed(context, alpha) : new _cardinalClosed.CardinalClosed(context, 0);
78 }
79 catmullRom.alpha = function (alpha) {
80 return custom(+alpha);
81 };
82 return catmullRom;
83}(0.5);
Note: See TracBrowser for help on using the repository browser.