source: node_modules/d3-shape/src/curve/basisOpen.js@ e4c61dd

Last change on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 1.1 KB
Line 
1import {point} from "./basis.js";
2
3function BasisOpen(context) {
4 this._context = context;
5}
6
7BasisOpen.prototype = {
8 areaStart: function() {
9 this._line = 0;
10 },
11 areaEnd: function() {
12 this._line = NaN;
13 },
14 lineStart: function() {
15 this._x0 = this._x1 =
16 this._y0 = this._y1 = NaN;
17 this._point = 0;
18 },
19 lineEnd: function() {
20 if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath();
21 this._line = 1 - this._line;
22 },
23 point: function(x, y) {
24 x = +x, y = +y;
25 switch (this._point) {
26 case 0: this._point = 1; break;
27 case 1: this._point = 2; break;
28 case 2: this._point = 3; var x0 = (this._x0 + 4 * this._x1 + x) / 6, y0 = (this._y0 + 4 * this._y1 + y) / 6; this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0); break;
29 case 3: this._point = 4; // falls through
30 default: point(this, x, y); break;
31 }
32 this._x0 = this._x1, this._x1 = x;
33 this._y0 = this._y1, this._y1 = y;
34 }
35};
36
37export default function(context) {
38 return new BasisOpen(context);
39}
Note: See TracBrowser for help on using the repository browser.