chunk-XWA3NEEY.js 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import {
  2. a as a2,
  3. r
  4. } from "./chunk-54X4RLMR.js";
  5. import {
  6. Z,
  7. ee,
  8. me,
  9. t
  10. } from "./chunk-MWIFVNKP.js";
  11. import {
  12. a
  13. } from "./chunk-TRK7CKWP.js";
  14. // node_modules/@arcgis/core/symbols/cim/Rasterizer.js
  15. var o = 512;
  16. var m = class {
  17. constructor(e) {
  18. this._resourceManager = e;
  19. }
  20. dispose() {
  21. this._rasterizationCanvas = null;
  22. }
  23. rasterizeJSONResource(s, o2, m2) {
  24. if (this._rasterizationCanvas || (this._rasterizationCanvas = document.createElement("canvas")), s.type === "simple-fill" || s.type === "esriSFS") {
  25. const [t2, r2, a3] = ee.rasterizeSimpleFill(this._rasterizationCanvas, s.style, o2);
  26. return { size: [r2, a3], image: new Uint32Array(t2.buffer), sdf: false, simplePattern: true, anchorX: 0, anchorY: 0 };
  27. }
  28. if (s.type === "simple-line" || s.type === "esriSLS" || s.type === "line" && s.dashTemplate) {
  29. let r2, a3;
  30. if (s.type === "simple-line" || s.type === "esriSLS")
  31. switch (r2 = me(s.style, s.cap), s.cap) {
  32. case "butt":
  33. a3 = "Butt";
  34. break;
  35. case "square":
  36. a3 = "Square";
  37. break;
  38. default:
  39. a3 = "Round";
  40. }
  41. else
  42. r2 = s.dashTemplate, a3 = s.cim.capStyle;
  43. const [i, n, o3] = ee.rasterizeSimpleLine(r2, a3);
  44. return { size: [n, o3], image: new Uint32Array(i.buffer), sdf: true, simplePattern: true, anchorX: 0, anchorY: 0 };
  45. }
  46. let l, c, f;
  47. if (s.type === "simple-marker" || s.type === "esriSMS" || s.type === "line-marker" ? (l = Z.fromSimpleMarker(s), f = r(l)) : s.cim && s.cim.type === "CIMHatchFill" ? (l = Z.fromCIMHatchFill(s.cim), c = new t(l.frame.xmin, -l.frame.ymax, l.frame.xmax - l.frame.xmin, l.frame.ymax - l.frame.ymin)) : s.cim.markerPlacement && s.cim.markerPlacement.type === "CIMMarkerPlacementInsidePolygon" ? (l = Z.fromCIMInsidePolygon(s.cim), c = new t(l.frame.xmin, -l.frame.ymax, l.frame.xmax - l.frame.xmin, l.frame.ymax - l.frame.ymin)) : (l = s.cim, f = r(l)), f && !m2) {
  48. const [e, t2, r2] = a2(f);
  49. return e ? { size: [t2, r2], image: new Uint32Array(e.buffer), sdf: true, simplePattern: true, anchorX: 0, anchorY: 0 } : null;
  50. }
  51. const [p, h, u, y, d] = Z.rasterize(this._rasterizationCanvas, l, c, this._resourceManager, !m2);
  52. return p ? { size: [h, u], image: new Uint32Array(p.buffer), sdf: false, simplePattern: false, anchorX: y, anchorY: d } : null;
  53. }
  54. rasterizeImageResource(e, t2, r2, a3) {
  55. this._rasterizationCanvas || (this._rasterizationCanvas = document.createElement("canvas")), this._rasterizationCanvas.width = e, this._rasterizationCanvas.height = t2;
  56. const i = this._rasterizationCanvas.getContext("2d");
  57. r2 instanceof ImageData ? i.putImageData(r2, 0, 0) : (r2.setAttribute("width", `${e}px`), r2.setAttribute("height", `${t2}px`), i.drawImage(r2, 0, 0, e, t2));
  58. const n = i.getImageData(0, 0, e, t2), m2 = new Uint8Array(n.data);
  59. if (a3) {
  60. for (const s of a3)
  61. if (s && s.oldColor && s.oldColor.length === 4 && s.newColor && s.newColor.length === 4) {
  62. const [e2, t3, r3, a4] = s.oldColor, [i2, n2, o2, l2] = s.newColor;
  63. if (e2 === i2 && t3 === n2 && r3 === o2 && a4 === l2)
  64. continue;
  65. for (let s2 = 0; s2 < m2.length; s2 += 4)
  66. e2 === m2[s2] && t3 === m2[s2 + 1] && r3 === m2[s2 + 2] && a4 === m2[s2 + 3] && (m2[s2] = i2, m2[s2 + 1] = n2, m2[s2 + 2] = o2, m2[s2 + 3] = l2);
  67. }
  68. }
  69. let l;
  70. for (let s = 0; s < m2.length; s += 4)
  71. l = m2[s + 3] / 255, m2[s] = m2[s] * l, m2[s + 1] = m2[s + 1] * l, m2[s + 2] = m2[s + 2] * l;
  72. let c = m2, f = e, p = t2;
  73. const h = o;
  74. if (f >= h || p >= h) {
  75. const r3 = f / p;
  76. r3 > 1 ? (f = h, p = Math.round(h / r3)) : (p = h, f = Math.round(h * r3)), c = new Uint8Array(4 * f * p);
  77. const a4 = new Uint8ClampedArray(c.buffer);
  78. a(m2, e, t2, a4, f, p, false);
  79. }
  80. return { size: [f, p], image: new Uint32Array(c.buffer), sdf: false, simplePattern: false, anchorX: 0, anchorY: 0 };
  81. }
  82. };
  83. export {
  84. m
  85. };
  86. //# sourceMappingURL=chunk-XWA3NEEY.js.map