# normalize-svg-coords

> Normalize coordinates in an SVG path to a specified range

Latest version **1.0.9** (published 2019-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install normalize-svg-coords
pnpm add normalize-svg-coords
yarn add normalize-svg-coords
bun add normalize-svg-coords
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2019-06-08 |
| First published | 2017-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 15 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Luke Mitchell |
| Maintainers | lukem512 |
| Keywords | svg, normalize, coordinate, range, clip, mask |

## Links

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

## Dependencies (2)

- [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

## Recent versions

- 1.0.9 (latest) — 2019-06-08
- 1.0.8 — 2019-06-08
- 1.0.7 — 2017-09-01
- 1.0.6 — 2017-07-24
- 1.0.5 — 2017-07-24
- 1.0.4 — 2017-07-24
- 1.0.3 — 2017-07-24
- 1.0.2 — 2017-07-19
- 1.0.1 — 2017-07-19
- 1.0.0 — 2017-03-30

## README

# normalize-svg-coords

[![Build Status](https://travis-ci.org/lukem512/normalize-svg-coords.svg?branch=master)](https://travis-ci.org/lukem512/normalize-svg-coords) ![Dependency Status](https://david-dm.org/lukem512/normalize-svg-coords.svg) [![npm](https://img.shields.io/npm/l/normalize-svg-coords.svg)](https://www.npmjs.com/package/normalize-svg-coords) [![npm](https://img.shields.io/npm/v/normalize-svg-coords.svg)](https://www.npmjs.com/package/normalize-svg-coords) [![npm](https://img.shields.io/npm/dm/normalize-svg-coords.svg)](https://www.npmjs.com/package/normalize-svg-coords)

Normalize coordinates in an SVG path to a specified range.

## Install

```
npm i --save normalize-svg-coords
```

## Usage

```js
const normalize = require('normalize-svg-coords');

const normalizedPath = normalize({
  viewBox: '0 0 400 460',
  path: 'M150.883 169.12c11.06-.887 20.275-7.079 24.422-17.256',
  min: 0,
  max: 1,
  asList: false
})

console.log(normalizedPath) // M0.3772 0.3677c0.0277 -0.0019 0.0507 -0.0154 0.0611 -0.0375
```

Specify a range, `min` to `max`, and provide the `path` and the corresponding
`viewBox`. The coordinates of the resulting path will all be within the
specified range whilst maintaining the shape.

The `viewBox` parameter may be passed as a `string` of 4 integers in the order
`xmin ymin xmax ymax` with spaces (` `) or commas (`,`) as a delimiter. The
`viewBox` may also be passed as an `object` or an `array`. If no `viewBox` is specified then one is inferred using [`svg-path-bounds`](https://npmjs.com/package/svg-path-bounds).

Set the `asList` parameter to `true` to output the normalized path as a segmented list.

```js
console.log(normalizedPath) // ['M', '0.3772', '0.3677'], ['c', '0.0277', '-0.0019', '0.0507', '-0.0154', '0.0611', '-0.0375']]
```

## Related Modules

[extract-svg-viewbox](https://github.com/lukem512/extract-svg-viewbox)

## License

MIT © Luke Mitchell

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