source: node_modules/victory-vendor/lib-vendor/d3-shape/src/curve/basis.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: 1.6 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.Basis = Basis;
7exports.default = _default;
8exports.point = point;
9function point(that, x, y) {
10 that._context.bezierCurveTo((2 * that._x0 + that._x1) / 3, (2 * that._y0 + that._y1) / 3, (that._x0 + 2 * that._x1) / 3, (that._y0 + 2 * that._y1) / 3, (that._x0 + 4 * that._x1 + x) / 6, (that._y0 + 4 * that._y1 + y) / 6);
11}
12function Basis(context) {
13 this._context = context;
14}
15Basis.prototype = {
16 areaStart: function () {
17 this._line = 0;
18 },
19 areaEnd: function () {
20 this._line = NaN;
21 },
22 lineStart: function () {
23 this._x0 = this._x1 = this._y0 = this._y1 = NaN;
24 this._point = 0;
25 },
26 lineEnd: function () {
27 switch (this._point) {
28 case 3:
29 point(this, this._x1, this._y1);
30 // falls through
31 case 2:
32 this._context.lineTo(this._x1, this._y1);
33 break;
34 }
35 if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
36 this._line = 1 - this._line;
37 },
38 point: function (x, y) {
39 x = +x, y = +y;
40 switch (this._point) {
41 case 0:
42 this._point = 1;
43 this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
44 break;
45 case 1:
46 this._point = 2;
47 break;
48 case 2:
49 this._point = 3;
50 this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6);
51 // falls through
52 default:
53 point(this, x, y);
54 break;
55 }
56 this._x0 = this._x1, this._x1 = x;
57 this._y0 = this._y1, this._y1 = y;
58 }
59};
60function _default(context) {
61 return new Basis(context);
62}
Note: See TracBrowser for help on using the repository browser.