# svg-path-to-css-polygon

> An overengineered library built just for Søren Birkemeyer 💌

Latest version **0.2.1** (published 2020-09-11) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install svg-path-to-css-polygon
pnpm add svg-path-to-css-polygon
yarn add svg-path-to-css-polygon
bun add svg-path-to-css-polygon
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2020-09-11 |
| First published | 2020-09-11 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 23.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Steven Petryk |
| Maintainers | stevenpetryk |

## Links

- npm: https://www.npmjs.com/package/svg-path-to-css-polygon
- npm.io page: https://npm.io/package/svg-path-to-css-polygon

## Dependencies (2)

- [tiny-invariant](https://npm.io/package/tiny-invariant.md) ^1.1.0
- [svg-path-parser](https://npm.io/package/svg-path-parser.md) ^1.1.0

## Recent versions

- 0.2.1 (latest) — 2020-09-11
- 0.1.0 — 2020-09-11

## README

# svg-path-to-css-polygon

An overengineered library built just for Søren Birkemeyer 💌

It's not a PostCSS plugin like I mentioned, just a function. But hopefully it helps. The source is pretty minimal. Should be possible to import into a PostCSS/Sass/something plugin.

## Usage

```bash
yarn add svg-path-to-css-polygon
```

```ts
import svgPathToCssPolygon from 'svg-path-to-css-polygon'

svgPathToCssPolygon(
  // Pass your SVG's viewbox
  { x: 0, y: 0, width: 100, height: 100 },
  // Then pass the path's `d` attribute
  'M 0 0 L 50 50 L 0 50 Z'
)

// => 'polygon(0% 0%, 50% 50%, 0% 50%)'
```

## Features:

- Supports arbitrary SVG viewboxes
- Supports absolute and relative commands

## Non-features:

- Does not support curves

## Notes:

- The "Z" closepath command is ignored, as CSS polygons are always closed.
- Repeated "M" moveto commands are treated identically to "L" lineto commands.

---
_Source: https://npm.io/package/svg-path-to-css-polygon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
