source: node_modules/d3-shape/src/curve/cardinalClosed.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.6 KB
RevLine 
[e4c61dd]1import noop from "../noop.js";
2import {point} from "./cardinal.js";
3
4export function CardinalClosed(context, tension) {
5 this._context = context;
6 this._k = (1 - tension) / 6;
7}
8
9CardinalClosed.prototype = {
10 areaStart: noop,
11 areaEnd: noop,
12 lineStart: function() {
13 this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 =
14 this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
15 this._point = 0;
16 },
17 lineEnd: function() {
18 switch (this._point) {
19 case 1: {
20 this._context.moveTo(this._x3, this._y3);
21 this._context.closePath();
22 break;
23 }
24 case 2: {
25 this._context.lineTo(this._x3, this._y3);
26 this._context.closePath();
27 break;
28 }
29 case 3: {
30 this.point(this._x3, this._y3);
31 this.point(this._x4, this._y4);
32 this.point(this._x5, this._y5);
33 break;
34 }
35 }
36 },
37 point: function(x, y) {
38 x = +x, y = +y;
39 switch (this._point) {
40 case 0: this._point = 1; this._x3 = x, this._y3 = y; break;
41 case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break;
42 case 2: this._point = 3; this._x5 = x, this._y5 = y; break;
43 default: point(this, x, y); break;
44 }
45 this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
46 this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
47 }
48};
49
50export default (function custom(tension) {
51
52 function cardinal(context) {
53 return new CardinalClosed(context, tension);
54 }
55
56 cardinal.tension = function(tension) {
57 return custom(+tension);
58 };
59
60 return cardinal;
61})(0);
Note: See TracBrowser for help on using the repository browser.