UNPKG

wind-barbs

Version:

A small utility to generate wind barb SVGs

1 lines 2.05 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.WindBarb=e():t.WindBarb=e()}(self,(()=>(()=>{"use strict";var t={d:(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{default:()=>d});const r={color:"#000000",rotationPoint:"stem"},o=Number(18)/2,n=Number(25)/2,i="2",l=2.9,s=6.85,d=(t,e=0,d)=>{const p=5*Math.round(t/5),{color:c=r.color,rotationPoint:y=r.rotationPoint}=d||{},a={attr:{viewBox:"0 0 18 25",xmlns:"http://www.w3.org/2000/svg",style:{transform:`rotate(${e}deg)`,transformOrigin:"stem"===y?"bottom center":"center center",height:"100%"}},children:[]};if(p<3)return a.children=[{type:"circle",attr:{cx:o.toString(),cy:n.toString(),r:5..toString(),stroke:c,strokeWidth:i,fill:"none"}}],a;let f=l,h=p;if(p>=50||p<8?a.children.push({type:"polyline",attr:{points:`${o},25 ${o},2.9`,fill:"none",stroke:c,strokeWidth:i}}):(a.children.push({type:"polyline",attr:{points:`${o},25 ${o},3.9 17.7,0.95`,fill:"none",stroke:c,strokeWidth:i}}),h-=10,f=s),p>=3&&p<8)return f=s,a.children.push({type:"line",attr:{x1:o.toString(),y1:f.toString(),x2:13.35.toString(),y2:(f-1.45).toString(),stroke:c,strokeWidth:i}}),a;for(;h>=50;)a.children.push({type:"path",attr:{d:`M${o},${f} \n L15,${f+2} \n L${o},${f+4} \n Z`,fill:c,stroke:c,strokeWidth:i}}),h-=50,f+=h>=50?5.5:7;for(;h>=10&&f!==l;)a.children.push({type:"line",attr:{x1:o.toString(),y1:f.toString(),x2:17.7.toString(),y2:(f-l).toString(),stroke:c,strokeWidth:i}}),h-=10,f=f==l?s:f+3;for(;h>=5;)a.children.push({type:"line",attr:{x1:o.toString(),y1:f.toString(),x2:13.35.toString(),y2:(f-1.45).toString(),stroke:c,strokeWidth:i}}),h-=5,f+=3;return a};return e})()));