| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.default = _default;
|
|---|
| 7 | exports.stepAfter = stepAfter;
|
|---|
| 8 | exports.stepBefore = stepBefore;
|
|---|
| 9 | function Step(context, t) {
|
|---|
| 10 | this._context = context;
|
|---|
| 11 | this._t = t;
|
|---|
| 12 | }
|
|---|
| 13 | Step.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 | };
|
|---|
| 55 | function _default(context) {
|
|---|
| 56 | return new Step(context, 0.5);
|
|---|
| 57 | }
|
|---|
| 58 | function stepBefore(context) {
|
|---|
| 59 | return new Step(context, 0);
|
|---|
| 60 | }
|
|---|
| 61 | function stepAfter(context) {
|
|---|
| 62 | return new Step(context, 1);
|
|---|
| 63 | } |
|---|