wind-barbs
Version:
A small utility to generate wind barb SVGs
1 lines • 1.66 kB
JavaScript
var t={d:(r,o)=>{for(var e in o)t.o(o,e)&&!t.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:o[e]})},o:(t,r)=>Object.prototype.hasOwnProperty.call(t,r)},r={};t.d(r,{A:()=>h});const o={color:"#000000",rotationPoint:"stem"},e=Number(18)/2,n=Number(25)/2,i="2",l=2.9,s=6.85,h=(t,r=0,h)=>{const a=5*Math.round(t/5),{color:p=o.color,rotationPoint:c=o.rotationPoint}=h||{},d={attr:{viewBox:"0 0 18 25",xmlns:"http://www.w3.org/2000/svg",style:{transform:`rotate(${r}deg)`,transformOrigin:"stem"===c?"bottom center":"center center",height:"100%"}},children:[]};if(a<3)return d.children=[{type:"circle",attr:{cx:e.toString(),cy:n.toString(),r:5..toString(),stroke:p,strokeWidth:i,fill:"none"}}],d;let g=l,y=a;if(a>=50||a<8?d.children.push({type:"polyline",attr:{points:`${e},25 ${e},2.9`,fill:"none",stroke:p,strokeWidth:i}}):(d.children.push({type:"polyline",attr:{points:`${e},25 ${e},3.9 17.7,0.95`,fill:"none",stroke:p,strokeWidth:i}}),y-=10,g=s),a>=3&&a<8)return g=s,d.children.push({type:"line",attr:{x1:e.toString(),y1:g.toString(),x2:13.35.toString(),y2:(g-1.45).toString(),stroke:p,strokeWidth:i}}),d;for(;y>=50;)d.children.push({type:"path",attr:{d:`M${e},${g} \n L15,${g+2} \n L${e},${g+4} \n Z`,fill:p,stroke:p,strokeWidth:i}}),y-=50,g+=y>=50?5.5:7;for(;y>=10&&g!==l;)d.children.push({type:"line",attr:{x1:e.toString(),y1:g.toString(),x2:17.7.toString(),y2:(g-l).toString(),stroke:p,strokeWidth:i}}),y-=10,g=g==l?s:g+3;for(;y>=5;)d.children.push({type:"line",attr:{x1:e.toString(),y1:g.toString(),x2:13.35.toString(),y2:(g-1.45).toString(),stroke:p,strokeWidth:i}}),y-=5,g+=3;return d};var a=r.A;export{a as default};