source: node_modules/d3-shape/src/curve/cardinalOpen.js@ a762898

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

Prototype 1.1

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[e4c61dd]1import {point} from "./cardinal.js";
2
3export function CardinalOpen(context, tension) {
4 this._context = context;
5 this._k = (1 - tension) / 6;
6}
7
8CardinalOpen.prototype = {
9 areaStart: function() {
10 this._line = 0;
11 },
12 areaEnd: function() {
13 this._line = NaN;
14 },
15 lineStart: function() {
16 this._x0 = this._x1 = this._x2 =
17 this._y0 = this._y1 = this._y2 = NaN;
18 this._point = 0;
19 },
20 lineEnd: function() {
21 if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath();
22 this._line = 1 - this._line;
23 },
24 point: function(x, y) {
25 x = +x, y = +y;
26 switch (this._point) {
27 case 0: this._point = 1; break;
28 case 1: this._point = 2; break;
29 case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break;
30 case 3: this._point = 4; // falls through
31 default: point(this, x, y); break;
32 }
33 this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
34 this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
35 }
36};
37
38export default (function custom(tension) {
39
40 function cardinal(context) {
41 return new CardinalOpen(context, tension);
42 }
43
44 cardinal.tension = function(tension) {
45 return custom(+tension);
46 };
47
48 return cardinal;
49})(0);
Note: See TracBrowser for help on using the repository browser.