# svg-path-sdf

> Get signed distance field for a svg path

Latest version **2.0.0** (published 2025-03-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install svg-path-sdf
pnpm add svg-path-sdf
yarn add svg-path-sdf
bun add svg-path-sdf
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2025-03-05 |
| First published | 2017-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 25.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 67 |
| Author | Dima Yv |
| Maintainers | dfcreative, dy |
| Keywords | sdf, svg, path, signed, distance, webgl, gl, stackgl |

## Links

- npm: https://www.npmjs.com/package/svg-path-sdf
- Repository: https://github.com/dy/svg-path-sdf
- Homepage: https://github.com/dy/svg-path-sdf#readme
- Issues: https://github.com/dy/svg-path-sdf/issues
- npm.io page: https://npm.io/package/svg-path-sdf

## Dependencies (4)

- [bitmap-sdf](https://npm.io/package/bitmap-sdf.md) ^1.0.0
- [is-svg-path](https://npm.io/package/is-svg-path.md) ^1.0.1
- [parse-svg-path](https://npm.io/package/parse-svg-path.md) ^0.1.2
- [svg-path-bounds](https://npm.io/package/svg-path-bounds.md) ^1.0.1

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2025-03-05
- 1.1.3 — 2018-12-13
- 1.1.2 — 2018-09-30
- 1.1.1 — 2017-08-24
- 1.1.0 — 2017-08-24
- 1.0.0 — 2017-08-23

## README

# svg-path-sdf [![experimental](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges)

Create signed distance field for an svg path data.

![svg-path-sdf](https://github.com/dy/svg-path-sdf/blob/master/preview.png?raw=true)

## Usage

[![npm install svg-path-sdf](https://nodei.co/npm/svg-path-sdf.png?mini=true)](https://npmjs.org/package/svg-path-sdf/)

```js
import pathSdf from 'svg-path-sdf'

const arr = pathSdf('M40,0A40,40 0 1,1 0,-40A40,40 0 0,1 40,0Z', {
	width: 200,
	height: 200
})
```

`arr` has `200×200` elements with value from `0..1` range, corresponding to distance. The path is drawn at the center of the sdf fitting to the minimum side.

## distances = pathSdf(path, options|shape?)

Option | Meaning
---|---
`width`, `height` | Output sdf size in px, defaults to `200×200`.
`cutoff`, `radius` | SDF parameters for [bitmap-sdf](https://github.com/dy/bitmap-sdf), by default detected from shape to fit min side.
`viewbox` | View box for the path data. If not defined, it is detected as path bounds via [svg-path-bounds](https://github.com/dy/svg-path-bounds).
`stroke` | Whether to stroke shape. Positive number will stroke outside the amount of pixels, negative number will stroke inside, `0`-ish will disable stroke.

## License

(c) 2017 Dmitry Iv. MIT License

Development supported by plot.ly.

<p align=center><a href="https://github.com/krishnized/license/">🕉</a></p>

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