A small utility to generate wind barb SVGs
npm install wind-barbsumd format. There are no dependencies.
exports Environments
bash
npm install wind-barbs
`
Alternatively, you can use a
The library will be available under the WindBarb namespace.
Usage
The only function as of now is:
generateWindBarbSvg(windSpeed, windDirection?, options?)
- windSpeed - Wind speed. Knots are usually used, but this library is unitless.
- windDirection (optional, default: 0) - Wind direction. This will rotate the barb by the number of degrees given (0-359)
- options (optional) - Options object when generating the SVG. Right now, the only option is which color the barb should be. The default is:
`javascript
{
color: #000000
}
`
$3
There are two ways that may be used for generating wind barb SVGs. The first builds SVGs via the DOM and can be used as such:
`javascript
import { generateWindBarbSvg } from 'wind-barbs'
const svg = generateWindBarbSvg(15, -90)
window.document.appendChild(svg)
`
Which will produce:
See examples/browser.html.
$3
The second way to use wind-barbs will produce a JSX element. Import from wind-barbs/react
`javascript
import { generateWindBarbSvg } from 'wind-barbs/react'
const MyComponent = () => {
const svg = generateWindBarbSvg(15, -90, { color: 'pink' })
return {svg}
}
`
This will produce the same SVG as shown previously.
$3
If your environment does not support exports in package.json, then you can use the bundled library, which contains the DOM and JSX-style functions. The type signature for this is:
`typescript
import { generateWindBarbSvg } from '../index'
import { generateWindBarbSvg as generateWindBarbSvgReact } from '../react/index'
export { generateWindBarbSvg, generateWindBarbSvgReact }
``