You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
738 B
32 lines
738 B
5 years ago
|
function Linear(context) {
|
||
|
this._context = context;
|
||
|
}
|
||
|
|
||
|
Linear.prototype = {
|
||
|
areaStart: function() {
|
||
|
this._line = 0;
|
||
|
},
|
||
|
areaEnd: function() {
|
||
|
this._line = NaN;
|
||
|
},
|
||
|
lineStart: function() {
|
||
|
this._point = 0;
|
||
|
},
|
||
|
lineEnd: function() {
|
||
|
if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
|
||
|
this._line = 1 - this._line;
|
||
|
},
|
||
|
point: function(x, y) {
|
||
|
x = +x, y = +y;
|
||
|
switch (this._point) {
|
||
|
case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
|
||
|
case 1: this._point = 2; // proceed
|
||
|
default: this._context.lineTo(x, y); break;
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
export default function(context) {
|
||
|
return new Linear(context);
|
||
|
}
|