import{lineLength as h}from"../geometry.js";import{polygonHachureLines as t}from"./scan-line-hachure.js";export class DashedFiller{constructor(h){this.helper=h}fillPolygon(h,s){const a=t(h,s);return{type:"fillSketch",ops:this.dashedLine(a,s)}}dashedLine(t,s){const a=s.dashOffset<0?s.hachureGap<0?4*s.strokeWidth:s.hachureGap:s.dashOffset,e=s.dashGap<0?s.hachureGap<0?4*s.strokeWidth:s.hachureGap:s.dashGap,o=[];return t.forEach((t=>{const r=h(t),c=Math.floor(r/(a+e)),n=(r+e-c*(a+e))/2;let i=t[0],l=t[1];i[0]>l[0]&&(i=t[1],l=t[0]);const p=Math.atan((l[1]-i[1])/(l[0]-i[0]));for(let h=0;h<c;h++){const t=h*(a+e),r=t+a,c=[i[0]+t*Math.cos(p)+n*Math.cos(p),i[1]+t*Math.sin(p)+n*Math.sin(p)],l=[i[0]+r*Math.cos(p)+n*Math.cos(p),i[1]+r*Math.sin(p)+n*Math.sin(p)];o.push(...this.helper.doubleLineOps(c[0],c[1],l[0],l[1],s))}})),o}}