UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.72 kB
import{bidiText as e}from"../../../../../../core/BidiText.js";import{pt2px as o,toPt as t}from"../../../../../../core/screenUtils.js";import{Alignment as i}from"../../../../../../symbols/cim/enums.js";import{getJustification as r,getXAnchorDirection as n,getYAnchorDirection as s}from"../../alignmentUtils.js";import{premultiplyAlphaRGBAArray as l,premultiplyAlphaRGBA as a}from"../../color.js";import{GLYPH_SIZE as m,MIN_MAX_ZOOM_PRECISION_FACTOR as h}from"../../definitions.js";import{i1616to32 as c}from"../../number.js";import{MaterialKeyBase as f}from"../../materialKey/MaterialKey.js";import{DEFAULT_MIN_ZOOM as d,DEFAULT_MAX_ZOOM as _,getMinMaxZoom as u}from"./util.js";import b from"./WGLBaseTextTemplate.js";import x from"./WGLMeshTemplate.js";const z=5;class g extends(b(x)){constructor(e,l,a,d,_,u,b,x,g,C,M,p,S,j,L,y,T,V,k,A,v,I,K,R){super(),this._xOffset=o(S),this._yOffset=o(j),this._decoration=C||"none",this._backgroundColor=I,this._borderLineColor=K,this._borderLineSize=R,this._color=_,this._haloColor=u,this._haloSize=Math.min(Math.floor(z*o(t(a))),127),this._size=Math.min(Math.round(o(l)),127);const W=Math.min(Math.round(o(d||l)),127);this._referenceSize=Math.round(Math.sqrt(256*W)),this._scale=this._size/m,this._angle=p,this._justify=r(b||"center"),this._xAlignD=n(b||"center"),this._yAlignD=s(x||"baseline"),this._baseline="baseline"===(x||"baseline"),this._bitset=(g===i.MAP?1:0)|(M?1:0)<<1;const B=f.load(e);B.sdf=!0,this._materialKey=B.data,this._lineWidth=o(L)||512,this._lineHeight=y||1,this._textPlacement=T,this._effects=V,this._isCIM=k??!1,this._minMaxZoom=c(Math.round(A*h),Math.round(v*h))}static fromText(o,t){const r=o.font?.size,n=new g(o.materialKey,r,o.haloSize||0,r,o.color&&l(o.color)||0,o.haloColor&&l(o.haloColor)||0,o.horizontalAlignment,o.verticalAlignment,i.SCREEN,o.font?.decoration,!1,o.angle||0,o.xoffset||0,o.yoffset||0,o.lineWidth||0,o.lineHeight||0,null,null,!1,d,_,o.backgroundColor&&l(o.backgroundColor),o.borderLineColor&&l(o.borderLineColor),o.borderLineSize),[,s]=e(o.text);return n.bindTextInfo(t??[],s),n._vertexBoundsScale=o.maxVVSize&&r?o.maxVVSize/r:1,n}static fromCIMText(o,t,i){const r=o.scaleFactor||1,n=o.size*o.sizeRatio*r,[s,l]=u(o.scaleInfo,i),m=new g(o.materialKey,n,o.outlineSize*o.sizeRatio,o.referenceSize,a(o.color),a(o.outlineColor),o.horizontalAlignment,o.verticalAlignment,o.alignment,o.decoration,o.colorLocked??!1,o.angle,o.offsetX*o.sizeRatio*r,o.offsetY*o.sizeRatio*r,512,1,o.markerPlacement,o.effects,!0,s,l,o.backgroundColor?a(o.backgroundColor):void 0,o.borderLineColor?a(o.borderLineColor):void 0,o.borderLineWidth),[,h]=e(o.text);return m.bindTextInfo(t,h),m._vertexBoundsScale=o.maxVVSize?o.maxVVSize/n:1,m}}export{g as default};