@scandit/web-datacapture-core
Version:
Scandit Data Capture SDK for the Web
1 lines • 1.75 kB
JavaScript
import {a}from'./chunk-IJQG3OU6.js';import {a as a$1}from'./chunk-KAFNKP6O.js';var b=class f extends a{constructor(n,t,h,e,c,s,r,P,p){super(n,t,h,e),this._centerLeft=c,this._topCenter=s,this._centerRight=r,this._bottomCenter=P,this._center=p;}get centerRight(){return this._centerRight}get center(){return this._center}get centerLeft(){return this._centerLeft}get topCenter(){return this._topCenter}get bottomCenter(){return this._bottomCenter}static fromJSON(n){let{topLeft:t,topRight:h,bottomRight:e,bottomLeft:c,centerLeft:s,topCenter:r,centerRight:P,bottomCenter:p,center:l}=n,i=a$1.fromJSON(t),m=a$1.fromJSON(h),O=a$1.fromJSON(e),S=a$1.fromJSON(c),g=a$1.fromJSON(s),J=a$1.fromJSON(r),N=a$1.fromJSON(P),u=a$1.fromJSON(p),x=a$1.fromJSON(l);return new f(i,m,O,S,g,J,N,u,x)}toJSONObject(){return {...super.toJSONObject(),center:this._center.toJSONObject(),bottomCenter:this._bottomCenter.toJSONObject(),topCenter:this._topCenter.toJSONObject(),centerLeft:this._centerLeft.toJSONObject(),centerRight:this._centerRight.toJSONObject()}}orderVerticesByPosition(){let n=[this.topLeft,this.topRight,this.bottomLeft,this.bottomRight],t=n.reduce((i,m)=>m.y<i.y?m:i),h=n.filter(i=>!i.equals(t));if(h.length===0)return this;let e=h.reduce((i,m)=>m.y<i.y?m:i),c=t.x<=e.x?t:e,s=t.x>e.x?t:e,r=n.filter(i=>!i.equals(c)&&!i.equals(s));if(r.length!==2)return this;let P=r[0].x<=r[1].x?r[0]:r[1],p=r[0].x>r[1].x?r[0]:r[1];return new f(c,s,p,P,new a$1((c.x+P.x)/2,(c.y+P.y)/2),new a$1((c.x+s.x)/2,(c.y+s.y)/2),new a$1((s.x+p.x)/2,(s.y+p.y)/2),new a$1((P.x+p.x)/2,(P.y+p.y)/2),this.center)}getArea(n){let t=[n.topLeft,n.topRight,n.bottomRight,n.bottomLeft,n.topLeft],h=0;for(let e=0;e<t.length-1;e++)h+=t[e].x*t[e+1].y-t[e+1].x*t[e].y;return Math.abs(h)/2}};export{b as a};