UNPKG

@idmwx/idmui-gl4

Version:

idm webgl4

47 lines (46 loc) 1.88 kB
import { d as u } from "./chunk-ANSXOGKI-8ea4f123.js"; import { l as g } from "./index-1599be89.js"; import "./chunk-3VYIPD3A-92fafc67.js"; import "axios"; import "vuetify"; import "vue"; import "mapbox-gl"; import "moment"; import "@idm-plugin/geo"; import "@idm-plugin/meteo"; import "echarts"; import "@turf/turf"; import "@idm-plugin/tag2"; import "@mapbox/sphericalmercator"; import "@idm-plugin/tag"; import "shpjs"; import "gif.js"; import "@idm-plugin/aliclient"; async function S(i, l) { let { scale: m = 1, width: o, height: p, meta: e = {} } = l, s = Number.isFinite(o), n = Number.isFinite(p), d = Number.isFinite(m) && m !== 1 || s || n; if (g() && d) return await u(i, { ...l, format: "png", quality: 1, meta: e }); let t = new Image(); if (t.decoding = "sync", t.loading = "eager", t.src = i, await t.decode(), s && n) t.style.width = `${o}px`, t.style.height = `${p}px`; else if (s) { let r = Number.isFinite(e.w0) ? e.w0 : t.naturalWidth, a = Number.isFinite(e.h0) ? e.h0 : t.naturalHeight, h = o / Math.max(1, r); t.style.width = `${o}px`, t.style.height = `${Math.round(a * h)}px`; } else if (n) { let r = Number.isFinite(e.w0) ? e.w0 : t.naturalWidth, a = Number.isFinite(e.h0) ? e.h0 : t.naturalHeight, h = p / Math.max(1, a); t.style.height = `${p}px`, t.style.width = `${Math.round(r * h)}px`; } else { let r = Math.round(t.naturalWidth * m), a = Math.round(t.naturalHeight * m); if (t.style.width = `${r}px`, t.style.height = `${a}px`, typeof i == "string" && i.startsWith("data:image/svg+xml")) try { let h = decodeURIComponent(i.split(",")[1]).replace(/width="[^"]*"/, `width="${r}"`).replace(/height="[^"]*"/, `height="${a}"`); i = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(h)}`, t.src = i; } catch { } } return t; } export { S as toImg, S as toSvg };