@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.92 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{pt2px as t,createScreenPoint as e,toPt as o}from"../../../core/screenUtils.js";import{getBasemapId as i,defaultBasemapGroups as n}from"../../support/utils.js";import{getCIMSymbolSize as r}from"../../../symbols/support/cimSymbolUtils.js";import{getSymbolOutlineColor as s,getSymbolOutlineSize as l,getColorFromSymbol as c}from"../../../symbols/support/utils.js";const u=n.light,p=n.dark,m=[...u,...p];function a(e){const o=e[0],i=s(o),n=l(o),u="cim"===o.type?r(o):"size"in o?o.size:"width"in o?o.width:null,p={outline:i&&null!=n?{color:i?.toArray(),width:`${t(n)}px`}:{color:[153,153,153,.25],width:"0.5px"},fillOpacity:.8,width:null!=n?`${t(n)}px`:"2px",size:null!=u?`${t(u)}px`:"8px"},m={stops:e.map((t=>c(t,1)?.toHex())).filter(Boolean),tags:["custom-scheme"],name:"custom"};return{commonProps:p,colorRampInfo:m}}function f(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b}function h(t,e){let o=0;if(t.length===e.length){let i=t.every(((t,o)=>f(t,e[o])));if(i)o=1;else{i=t.slice().reverse().every(((t,o)=>f(t,e[o]))),i&&(o=-1)}}return o}function d(t){const o=t.width,i=t.height;let n=t.pixelSizeAt(t.toMap(e(.5*o,.5*i),{exclude:[]}));if(n<=0&&(n=t.pixelSizeAt(t.toMap(e(.5*o,.95*i),{exclude:[]})),n<=0&&"camera"in t)){const e=t.camera.position.clone();e.z=0,n=2*t.pixelSizeAt(e)}return n}function x(e,i){return Math.ceil(d(i)*t(o(e)))}function g(t){const e=i(t,m,!1);return e?u.includes(e)?"light":p.includes(e)?"dark":void 0:null}function y(t){if(!t)return[];const e=new Set,o=[t.primaryScheme];t.secondarySchemes&&o.push(...t.secondarySchemes);for(const i of o)i&&"tags"in i&&i.tags&&i.tags.forEach((t=>e.add(t)));return[...e]}export{g as getBasemapTheme,a as getColorSchemeDefinition,d as getPixelSize,y as getTagsFromSchemes,h as hasIdenticalColors,x as toWorldScale};