2 lines
28 KiB
JavaScript
2 lines
28 KiB
JavaScript
|
|
import{a as g}from"./chunk-AQ6EADP3.mjs";function tt(a,t,s){if(a&&a.length){let[e,n]=t,o=Math.PI/180*s,r=Math.cos(o),h=Math.sin(o);for(let i of a){let[l,c]=i;i[0]=(l-e)*r-(c-n)*h+e,i[1]=(l-e)*h+(c-n)*r+n}}}g(tt,"t");function Wt(a,t){return a[0]===t[0]&&a[1]===t[1]}g(Wt,"e");function Et(a,t,s,e=1){let n=s,o=Math.max(t,.1),r=a[0]&&a[0][0]&&typeof a[0][0]=="number"?[a]:a,h=[0,0];if(n)for(let l of r)tt(l,h,n);let i=(function(l,c,d){let p=[];for(let k of l){let w=[...k];Wt(w[0],w[w.length-1])||w.push([w[0][0],w[0][1]]),w.length>2&&p.push(w)}let u=[];c=Math.max(c,.1);let f=[];for(let k of p)for(let w=0;w<k.length-1;w++){let v=k[w],P=k[w+1];if(v[1]!==P[1]){let x=Math.min(v[1],P[1]);f.push({ymin:x,ymax:Math.max(v[1],P[1]),x:x===v[1]?v[0]:P[0],islope:(P[0]-v[0])/(P[1]-v[1])})}}if(f.sort(((k,w)=>k.ymin<w.ymin?-1:k.ymin>w.ymin?1:k.x<w.x?-1:k.x>w.x?1:k.ymax===w.ymax?0:(k.ymax-w.ymax)/Math.abs(k.ymax-w.ymax))),!f.length)return u;let M=[],b=f[0].ymin,y=0;for(;M.length||f.length;){if(f.length){let k=-1;for(let w=0;w<f.length&&!(f[w].ymin>b);w++)k=w;f.splice(0,k+1).forEach((w=>{M.push({s:b,edge:w})}))}if(M=M.filter((k=>!(k.edge.ymax<=b))),M.sort(((k,w)=>k.edge.x===w.edge.x?0:(k.edge.x-w.edge.x)/Math.abs(k.edge.x-w.edge.x))),(d!==1||y%c==0)&&M.length>1)for(let k=0;k<M.length;k+=2){let w=k+1;if(w>=M.length)break;let v=M[k].edge,P=M[w].edge;u.push([[Math.round(v.x),b],[Math.round(P.x),b]])}b+=d,M.forEach((k=>{k.edge.x=k.edge.x+d*k.edge.islope})),y++}return u})(r,o,e);if(n){for(let l of r)tt(l,h,-n);(function(l,c,d){let p=[];l.forEach((u=>p.push(...u))),tt(p,c,d)})(i,h,-n)}return i}g(Et,"s");function V(a,t){var s;let e=t.hachureAngle+90,n=t.hachureGap;n<0&&(n=4*t.strokeWidth),n=Math.round(Math.max(n,.1));let o=1;return t.roughness>=1&&(((s=t.randomizer)===null||s===void 0?void 0:s.next())||Math.random())>.7&&(o=n),Et(a,n,e,o||1)}g(V,"n");var F=class{static{g(this,"o")}constructor(t){this.helper=t}fillPolygons(t,s){return this._fillPolygons(t,s)}_fillPolygons(t,s){let e=V(t,s);return{type:"fillSketch",ops:this.renderLines(e,s)}}renderLines(t,s){let e=[];for(let n of t)e.push(...this.helper.doubleLineOps(n[0][0],n[0][1],n[1][0],n[1][1],s));return e}};function Y(a){let t=a[0],s=a[1];return Math.sqrt(Math.pow(t[0]-s[0],2)+Math.pow(t[1]-s[1],2))}g(Y,"a");var ot=class extends F{static{g(this,"h")}fillPolygons(t,s){let e=s.hachureGap;e<0&&(e=4*s.strokeWidth),e=Math.max(e,.1);let n=V(t,Object.assign({},s,{hachureGap:e})),o=Math.PI/180*s.hachureAngle,r=[],h=.5*e*Math.cos(o),i=.5*e*Math.sin(o);for(let[l,c]of n)Y([l,c])&&r.push([[l[0]-h,l[1]+i],[...c]],[[l[0]+h,l[1]-i],[...c]]);return{type:"fillSketch",ops:this.renderLines(r,s)}}},ht=class extends F{static{g(this,"r")}fillPolygons(t,s){let e=this._fillPolygons(t,s),n=Object.assign({},s,{hachureAngle:s.hachureAngle+90}),o=this._fillPolygons(t,n);return e.ops=e.ops.concat(o.ops),e}},rt=class{static{g(this,"i")}constructor(t){this.helper=t}fillPolygons(t,s){let e=V(t,s=Object.assign({},s,{hachureAngle:0}));return this.dotsOnLines(e,s)}dotsOnLines(t,s){let e=[],n=s.hachureGap;n<0&&(n=4*s.strokeWidth),n=Math.max(n,.1);let o=s.fillWeight;o<0&&(o=s.strokeWidth/2);let r=n/4;for(let h of t){let i=Y(h),l=i/n,c=Math.ceil(l)-1,d=i-c*n,p=(h[0][0]+h[1][0])/2-n/4,u=Math.min(h[0][1],h[1][1]);for(let f=0;f<c;f++){let M=u+d+f*n,b=p-r+2*Math.random()*r,y=M-r+2*Math.random()*r,k=this.helper.ellipse(b,y,o,o,s);e.push(...k.ops)}}return{type:"fillSketch",ops:e}}},it=class{static{g(this,"c")}constructor(t){this.helper=t}fillPolygons(t,s){let e=V(t,s);return{type:"fillSketch",ops:this.dashedLine(e,s)}}dashedLine(t,s){let e=s.dashOffset<0?s.hachureGap<0?4*s.strokeWidth:s.hachureGap:s.dashOffset,n=s.dashGap<0?s.hachureGap<0?4*s.strokeWidth:s.hachureGap:s.dashGap,o=[];return t.forEach((r=>{let h=Y(r),i=Math.floor(h/(e+n)),l=(h+n-i*(e+n))/2,c=r[0],d=r[1];c[0]>d[0]&&(c=r[1],d=r[0]);let p=Math.atan((d[1]-c[1])/(d[0]-c[0]));for(let u=0;u<i;u++){let f=u*(e+n),M=f+e,b=[c[0]+f*Math.cos(p)+l*Math.cos(p),c[1]+f*Math.sin(p)+l*Math.sin(p)],y=[c[0]+M*Math.cos(p)+l*Math.cos(p),c[1]+M*Math.sin(p)+l*Math.sin(p)];o.push(...this.helper.doubleLi
|