class CoordSystem{ /** * Создает ненормированную систему координат с началом в x0,y0 и направлением x1,y1 * @param {*} x0 * @param {*} y0 * @param {*} x1 * @param {*} y1 * @returns */ constructor(x0, y0, x1, y1) { this.x0 = x0 this.y0 = y0 this.x1 = x1 this.y1 = y1 } scale(k){ this.x1 *= k this.y1 *= k return this } move(dx, dy){ this.x0 += dx this.y0 += dy this.x1 += dx this.y1 += dy return this } moveto(x, y){ let dx = x - this.x0 let dy = y - this.y0 return this.move(dx, dy) } flipx(){ let x = this.x0 this.x0 = this.x1 this.x1 = x // this.x0 += 500 // this.x1 = 2 * this.x0 - this.x1 + 500 return this } flipy(){ this.y1 = 2 * this.y0 - this.y1 return this } clone(){ return new CoordSystem(this.x0, this.y0, this.x1, this.y1) } }; module.exports = CoordSystem module.exports.default = CoordSystem