@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.65 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{fromValues as t,create as h}from"../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";class i{constructor(i,e,s,r){this.transformedX=0,this.transformedY=0,this.center=t(i,e),this.centerT=h(),this.halfWidth=s/2,this.halfHeight=r/2,this.width=s,this.height=r}get x(){return this.center[0]}get y(){return this.center[1]}get blX(){return this.center[0]+this.halfWidth}get blY(){return this.center[1]+this.halfHeight}get trX(){return this.center[0]-this.halfWidth}get trY(){return this.center[1]-this.halfHeight}get xmin(){return this.x-this.halfWidth}get xmax(){return this.x+this.halfWidth}get ymin(){return this.y-this.halfHeight}get ymax(){return this.y+this.halfHeight}set x(t){this.center[0]=t}set y(t){this.center[1]=t}clone(){return new i(this.x,this.y,this.width,this.height)}serialize(t){return t.writeF32(this.center[0]),t.writeF32(this.center[1]),t.push(this.width),t.push(this.height),t}findCollisionDelta(t,h=4){const i=Math.abs(t.centerT[0]-this.centerT[0]),e=Math.abs(t.centerT[1]-this.centerT[1]),s=(t.halfWidth+this.halfWidth+h)/i,r=(t.halfHeight+this.halfHeight+h)/e,n=Math.min(s,r);return Math.log2(n)}extend(t){const h=Math.min(this.xmin,t.xmin),i=Math.min(this.ymin,t.ymin),e=Math.max(this.xmax,t.xmax)-h,s=Math.max(this.ymax,t.ymax)-i,r=h+e/2,n=i+s/2;this.width=e,this.height=s,this.halfWidth=e/2,this.halfHeight=s/2,this.x=r,this.y=n}static deserialize(t){const h=t.readF32(),e=t.readF32(),s=t.readInt32(),r=t.readInt32();return new i(h,e,s,r)}}export{i as default};