@haxtheweb/haxcms-nodejs
Version:
HAXcms single and multisite nodejs server, api, and administration
1 lines • 687 B
JavaScript
import{lineLength as t}from"../geometry.js";import{polygonHachureLines as e}from"./scan-line-hachure.js";export class DotFiller{constructor(t){this.helper=t}fillPolygon(t,o){o=Object.assign({},o,{hachureAngle:0});const s=e(t,o);return this.dotsOnLines(s,o)}dotsOnLines(e,o){const s=[];let r=o.hachureGap;r<0&&(r=4*o.strokeWidth),r=Math.max(r,.1);let h=o.fillWeight;h<0&&(h=o.strokeWidth/2);const n=r/4;for(const l of e){const e=t(l),i=e/r,c=Math.ceil(i)-1,a=e-c*r,p=(l[0][0]+l[1][0])/2-r/4,m=Math.min(l[0][1],l[1][1]);for(let t=0;t<c;t++){const e=m+a+t*r,l=p-n+2*Math.random()*n,i=e-n+2*Math.random()*n,c=this.helper.ellipse(l,i,h,h,o);s.push(...c.ops)}}return{type:"fillSketch",ops:s}}}