1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
export default class Polygon { constructor() { this._ = []; } moveTo(x, y) { this._.push([x, y]); } closePath() { this._.push(this._[0].slice()); } lineTo(x, y) { this._.push([x, y]); } value() { return this._.length ? this._ : null; } }