source: node_modules/victory-vendor/lib-vendor/d3-shape/src/curve/step.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.default = _default;
7exports.stepAfter = stepAfter;
8exports.stepBefore = stepBefore;
9function Step(context, t) {
10 this._context = context;
11 this._t = t;
12}
13Step.prototype = {
14 areaStart: function () {
15 this._line = 0;
16 },
17 areaEnd: function () {
18 this._line = NaN;
19 },
20 lineStart: function () {
21 this._x = this._y = NaN;
22 this._point = 0;
23 },
24 lineEnd: function () {
25 if (0 < this._t && this._t < 1 && this._point === 2) this._context.lineTo(this._x, this._y);
26 if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
27 if (this._line >= 0) this._t = 1 - this._t, this._line = 1 - this._line;
28 },
29 point: function (x, y) {
30 x = +x, y = +y;
31 switch (this._point) {
32 case 0:
33 this._point = 1;
34 this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
35 break;
36 case 1:
37 this._point = 2;
38 // falls through
39 default:
40 {
41 if (this._t <= 0) {
42 this._context.lineTo(this._x, y);
43 this._context.lineTo(x, y);
44 } else {
45 var x1 = this._x * (1 - this._t) + x * this._t;
46 this._context.lineTo(x1, this._y);
47 this._context.lineTo(x1, y);
48 }
49 break;
50 }
51 }
52 this._x = x, this._y = y;
53 }
54};
55function _default(context) {
56 return new Step(context, 0.5);
57}
58function stepBefore(context) {
59 return new Step(context, 0);
60}
61function stepAfter(context) {
62 return new Step(context, 1);
63}
Note: See TracBrowser for help on using the repository browser.