@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 957 B
JavaScript
function t(t,h,i,e,l,d,n,o){t.ignorePadding&&(e={left:0,right:0,top:0,bottom:0});let u=null;null!=t.width&&null!=t.height?u=[t.width,t.height]:null==t.width&&null!=t.height?u=[t.height,t.height]:null!=t.width&&null==t.height?u=[t.width,t.width]:null==t.width&&null==t.height&&(u=null);const r=i[0]-(e.left+e.right),a=i[1]-(e.top+e.bottom);let g,w,c=t.area||{x:0,y:0,width:r,height:a};if(u){const t=r/a,h=u[0]/u[1];if(h>t){const t=c.width/h;c={x:c.x,y:Math.round(c.y+(c.height-t)/2),width:c.width,height:Math.round(t)}}else{const t=c.height*h;c={x:Math.round(c.x+(c.width-t)/2),y:c.y,width:Math.round(t),height:c.height}}}else u=[c.width,c.height];u[0]>c.width?(g=Math.min(u[0]/c.width,h),w=u[0]/c.width/g):(g=1,w=u[0]/c.width);return{resolutionScale:g,cropArea:{x:Math.round((c.x+e.left)*g),y:Math.round((c.y+e.top)*g),width:Math.round(c.width*g),height:Math.round(c.height*g)},outputScale:w,format:l,quality:d,children:n,rotation:o}}export{t as default};