UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.42 kB
import{pt2px as t}from"../../../../../../core/screenUtils.js";import{premultiplyAlphaRGBAArray as e,premultiplyAlphaRGBA as l}from"../../color.js";import{BITSET_GENERIC_LOCK_COLOR as i,BITSET_FILL_RANDOM_PATTERN_OFFSET as o,BITSET_GENERIC_CONSIDER_ALPHA_ONLY as r,BITSET_FILL_HAS_UNRESOLVED_REPLACEMENT_COLOR as s,SPRITE_PADDING as a,MIN_MAX_ZOOM_PRECISION_FACTOR as n,PICTURE_FILL_COLOR as m}from"../../definitions.js";import{degToByte as f}from"../../GeometryUtils.js";import{i1616to32 as c,i8888to32 as h}from"../../number.js";import{FillMaterialKey as u}from"../../materialKey/MaterialKey.js";import{getMinMaxZoom as d,DEFAULT_MIN_ZOOM as p,DEFAULT_MAX_ZOOM as y}from"./util.js";import x from"./WGLBaseFillTemplate.js";import M from"./WGLMeshTemplate.js";const j=128;class w extends(x(M)){constructor(t,e,l,i,o,r,s,a,m,f,d,p,y,x,M,j){super(),this._effects=x;const w=u.load(t);e&&(w.sdf=e.sdf,w.pattern=!0,w.textureBinding=e.textureBinding),this.fillColor=l,this.tl=i,this.br=o,this.aux21=c(r,s),this.aux22=c(a,m),this.aux3=h(f,d,p,0),this._bitset=y,this._minMaxZoom=c(Math.round(M*n),Math.round(j*n)),this._materialKey=w.data}static fromCIMFill(e,n,m){const h=e.color,u=h&&l(h)||0,p=e.materialKey,[y,x]=d(e.scaleInfo,m),M=(e.colorLocked?i:0)|(e.applyRandomOffset?o:0)|(e.sampleAlphaOnly?r:0)|(e.hasUnresolvedReplacementColor?s:0);if(!n)return new w(p,null,u,0,0,0,0,0,0,0,0,0,M,e.effects,y,x);const{rect:g,width:F,height:K}=n,_=e.scaleX||1,b=g.x+a,L=g.y+a,C=b+F,T=L+K,A=t(e.height);let B=_*A;"CIMHatchFill"===e.cim.type&&(B*=F/K);let G=Math.round(A);G<=0&&(G=T-L);let I=Math.round(B);I<=0&&(I=C-b);const R=t(e.offsetX||0),S=t(-e.offsetY||0),U=c(b,L),O=c(C,T);return new w(p,n,u,U,O,I,G,R,S,j,j,f(e.angle),M,e.effects,y,x)}static fromSimpleFill(t,l,o=!1){const{color:r}=t,s=r&&"esriSFSNull"!==t.style&&e(r)||0,n=o?i:0,m=t.materialKey;let f;if(l){const{rect:t,width:e,height:i,pixelRatio:o}=l,r=t.x+a,h=t.y+a,u=r+e,d=h+i,x=c(r,h),M=c(u,d);f=new w(m,l,s,x,M,e/o,i/o,0,0,j,j,0,n,null,p,y)}else f=new w(m,null,s,0,0,0,0,0,0,0,0,0,n,null,p,y);return f._maybeAddLineTemplate(t),f}static fromPictureFill(e,l,o=!1){const r=m,{rect:s,width:n,height:f}=l,h=s.x+a,u=s.y+a,d=h+n,x=u+f,M=c(h,u),g=c(d,x),F=Math.round(t(e.width)),K=Math.round(t(e.height)),_=t(e.xoffset),b=t(-e.yoffset),L=e.materialKey,C=o?i:0,T=new w(L,l,r,M,g,F,K,_,b,j*e.xscale,j*e.yscale,0,C,null,p,y);return T._maybeAddLineTemplate(e),T}}export{w as default};