https://github.com/nickersoft/svg-pathgen
A declarative generator for SVG path strings ⚒️
https://github.com/nickersoft/svg-pathgen
Last synced: about 2 months ago
JSON representation
A declarative generator for SVG path strings ⚒️
- Host: GitHub
- URL: https://github.com/nickersoft/svg-pathgen
- Owner: Nickersoft
- Created: 2024-05-13T00:21:10.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2026-01-10T08:00:06.000Z (about 2 months ago)
- Last Synced: 2026-01-11T02:26:24.658Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 33.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
PathGen is a tiny, zero-dependency path generator based on the [now outdated path generator library](https://github.com/mathisonian/svg-path-generator) by [Matthew Conlen](https://github.com/mathisonian). It aims to provide a declarative way to write SVG paths, as the SVG [`d` commands](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d) can be pretty hard to read at a glance.
This library has full TypeScript support and should be fairly intuitive to use.
You can use it as follows:
```typescript
const path = new Path("M 20 30")
.moveTo(10, 25)
.lineTo(10, 75)
.lineTo(60, 75)
.lineTo(10, 25)
.close()
.end();
console.log(path); // M 20 30 10 25 L 10 75 60 75 10 25 Z
```
You can install it via your favorite NPM package manager:
```
$ npm install svg-pathgen
$ bun add svg-pathgen
$ pnpm add svg-pathgen
$ yarn add svg-pathgen
```