@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 2.62 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as t}from"tslib";import o from"../../core/Accessor.js";import{property as r,subclass as e}from"../../core/accessorSupport/decorators.js";import{negativeInfinity as s,pad as i,expandWithNestedArray as l,create as n,width as a,height as h}from"../../geometry/support/aaBoundingRect.js";import{tsx as d}from"../../widgets/support/widget.js";let p=class extends o{constructor(t){super(t),this.coordinates=void 0,this.strokeDash=[],this.strokeWidth=1,this.strokeColor=[0,0,0,1],this.strokeDashColor=[255,255,255,1],this.fillColor=[0,0,0,0],this.visible=!0,this.isDecoration=!0}get _strokeStyle(){const t=this.strokeColor;return`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}get _strokeBackgroundStyle(){const t=this.strokeDashColor;return`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}get _fillStyle(){const t=this.fillColor;return`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}get _renderCoordinates(){const t=[];if(!this.coordinates)return{coordinates:t,rect:s};const o=i(l(n(s),this.coordinates),2*this.strokeWidth);o[0]=Math.floor(o[0]),o[1]=Math.floor(o[1]),o[2]=Math.ceil(o[2]+.5),o[3]=Math.ceil(o[3]+.5);for(const r of this.coordinates)t.push([Math.floor(r[0]-o[0])+.5,Math.floor(r[1]-o[1])+.5]);return t.reverse(),{coordinates:t,rect:o}}render(){const{coordinates:t,rect:o}=this._renderCoordinates,r=a(o),e=h(o);return d("div",{classes:{"esri-outline-overlay-item":!0},styles:{left:o[0]+"px",top:o[1]+"px",width:r+"px",height:e+"px",visibility:this.visible?"visible":"hidden"}},d("svg",{height:e,styles:{display:"block"},width:r},d("polygon",{fill:this._fillStyle,points:t.map(([t,o])=>`${t},${o}`).join(" "),stroke:this._strokeBackgroundStyle,"stroke-width":this.strokeWidth}),d("polygon",{fill:"transparent",points:t.map(([t,o])=>`${t},${o}`).join(" "),stroke:this._strokeStyle,"stroke-dasharray":this.strokeDash.length?this.strokeDash.join(" "):void 0,"stroke-width":this.strokeWidth})))}renderCanvas(){}};t([r()],p.prototype,"coordinates",void 0),t([r()],p.prototype,"strokeDash",void 0),t([r()],p.prototype,"strokeWidth",void 0),t([r()],p.prototype,"strokeColor",void 0),t([r()],p.prototype,"strokeDashColor",void 0),t([r()],p.prototype,"fillColor",void 0),t([r()],p.prototype,"visible",void 0),t([r()],p.prototype,"isDecoration",void 0),t([r({readOnly:!0})],p.prototype,"_strokeStyle",null),t([r({readOnly:!0})],p.prototype,"_strokeBackgroundStyle",null),t([r({readOnly:!0})],p.prototype,"_fillStyle",null),t([r({readOnly:!0})],p.prototype,"_renderCoordinates",null),p=t([e("esri.views.overlay.OutlineOverlayItem")],p);export{p as default};