/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import t from"./LineImagePattern3D.js";async function e(e){const n=new Image;n.src=e.url,n.crossOrigin="Anonymous",await n.decode();const o=new OffscreenCanvas(n.width,n.height).getContext("2d");if(null==o)throw new Error("Could not get 2D context from canvas");o.drawImage(n,0,0);const r=o.getImageData(0,0,n.width,n.height);return new t({image:r,length:e.lengthMeters,width:e.widthMeters})}function n(e){const n=o(e.stipplePattern,e.widthMeters/e.lengthMeters);return new t({image:n,length:e.lengthMeters,width:e.widthMeters})}function o(t,e){const n=Math.max(...t.map(t=>t.length)),o=t.length;let r=300,a=e*r;const s=Math.floor(a/o),h=Math.floor(r/n);a=s*o,r=h*n;const i=new Uint8ClampedArray(r*a*4);i.fill(255);for(let l=0;l<a;l++){const e=Math.floor(l/s);for(let n=0;n<r;n++){const o=Math.floor(n/h),a=1===(t[e]?.[o]??0)?255:0,s=4*(l*r+n);i[s+0]=255,i[s+1]=255,i[s+2]=255,i[s+3]=a}}return new ImageData(i,r,a)}export{n as lineImagePatternFromArray,e as lineImagePatternFromUrl};
