UNPKG

fabric

Version:

Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.

2 lines 1.99 kB
import{cos as e}from"./util/misc/cos.min.mjs";import{sin as t}from"./util/misc/sin.min.mjs";var n=class n{constructor(e=0,t=0){typeof e==`object`?(this.x=e.x,this.y=e.y):(this.x=e,this.y=t)}add(e){return new n(this.x+e.x,this.y+e.y)}addEquals(e){return this.x+=e.x,this.y+=e.y,this}scalarAdd(e){return new n(this.x+e,this.y+e)}scalarAddEquals(e){return this.x+=e,this.y+=e,this}subtract(e){return new n(this.x-e.x,this.y-e.y)}subtractEquals(e){return this.x-=e.x,this.y-=e.y,this}scalarSubtract(e){return new n(this.x-e,this.y-e)}scalarSubtractEquals(e){return this.x-=e,this.y-=e,this}multiply(e){return new n(this.x*e.x,this.y*e.y)}scalarMultiply(e){return new n(this.x*e,this.y*e)}scalarMultiplyEquals(e){return this.x*=e,this.y*=e,this}divide(e){return new n(this.x/e.x,this.y/e.y)}scalarDivide(e){return new n(this.x/e,this.y/e)}scalarDivideEquals(e){return this.x/=e,this.y/=e,this}eq(e){return this.x===e.x&&this.y===e.y}lt(e){return this.x<e.x&&this.y<e.y}lte(e){return this.x<=e.x&&this.y<=e.y}gt(e){return this.x>e.x&&this.y>e.y}gte(e){return this.x>=e.x&&this.y>=e.y}lerp(e,t=.5){return t=Math.max(Math.min(1,t),0),new n(this.x+(e.x-this.x)*t,this.y+(e.y-this.y)*t)}distanceFrom(e){let t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}midPointFrom(e){return this.lerp(e)}min(e){return new n(Math.min(this.x,e.x),Math.min(this.y,e.y))}max(e){return new n(Math.max(this.x,e.x),Math.max(this.y,e.y))}toString(){return`${this.x},${this.y}`}setXY(e,t){return this.x=e,this.y=t,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setFromPoint(e){return this.x=e.x,this.y=e.y,this}swap(e){let t=this.x,n=this.y;this.x=e.x,this.y=e.y,e.x=t,e.y=n}clone(){return new n(this.x,this.y)}rotate(i,a=r){let o=t(i),s=e(i),c=this.subtract(a);return new n(c.x*s-c.y*o,c.x*o+c.y*s).add(a)}transform(e,t=!1){return new n(e[0]*this.x+e[2]*this.y+(t?0:e[4]),e[1]*this.x+e[3]*this.y+(t?0:e[5]))}};const r=new n(0,0);export{n as Point,r as ZERO}; //# sourceMappingURL=Point.min.mjs.map