import noop_default from "../noop.js";
import { point } from "./basis.js";
function BasisClosed(e) {
	this._context = e;
}
BasisClosed.prototype = {
	areaStart: noop_default,
	areaEnd: noop_default,
	lineStart: function() {
		this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN, this._point = 0;
	},
	lineEnd: function() {
		switch (this._point) {
			case 1:
				this._context.moveTo(this._x2, this._y2), this._context.closePath();
				break;
			case 2:
				this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3), this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3), this._context.closePath();
				break;
			case 3:
				this.point(this._x2, this._y2), this.point(this._x3, this._y3), this.point(this._x4, this._y4);
				break;
		}
	},
	point: function(e, r) {
		switch (e = +e, r = +r, this._point) {
			case 0:
				this._point = 1, this._x2 = e, this._y2 = r;
				break;
			case 1:
				this._point = 2, this._x3 = e, this._y3 = r;
				break;
			case 2:
				this._point = 3, this._x4 = e, this._y4 = r, this._context.moveTo((this._x0 + 4 * this._x1 + e) / 6, (this._y0 + 4 * this._y1 + r) / 6);
				break;
			default:
				point(this, e, r);
				break;
		}
		this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = r;
	}
};
function basisClosed_default(e) {
	return new BasisClosed(e);
}
export { basisClosed_default as default };
