# normalize-path-scale

> normalizes a 2D path to its bounding box

Latest version **2.0.0** (published 2015-10-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install normalize-path-scale
pnpm add normalize-path-scale
yarn add normalize-path-scale
bun add normalize-path-scale
```

## 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 | 2.0.0 |
| Published | 2015-10-03 |
| First published | 2014-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | normalize, get, bounding, box, bounds, bounded, norm, normal, unit, scale |

## Links

- npm: https://www.npmjs.com/package/normalize-path-scale
- Repository: https://github.com/mattdesl/normalize-path-scale
- Issues: https://github.com/mattdesl/normalize-path-scale/issues
- npm.io page: https://npm.io/package/normalize-path-scale

## Dependencies (2)

- [unlerp](https://npm.io/package/unlerp.md) ^1.0.1
- [bound-points](https://npm.io/package/bound-points.md) ^1.0.0

## Alternatives

- [react-native-root-siblings](https://npm.io/package/react-native-root-siblings.md) — 102.9K weekly downloads
- [post-robot](https://npm.io/package/post-robot.md) — 93.7K weekly downloads
- [@praxisui/dialog](https://npm.io/package/@praxisui/dialog.md) — 2.0K weekly downloads
- [easy-toggle-state](https://npm.io/package/easy-toggle-state.md) — 350 weekly downloads
- [ngx-lightbox-evp](https://npm.io/package/ngx-lightbox-evp.md) — 19 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2015-10-03
- 1.1.1 — 2014-11-08
- 1.1.0 — 2014-11-08
- 1.0.1 — 2014-11-05
- 1.0.0 — 2014-11-05

## README

# normalize-path-scale

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Normalizes a 2D path to its bounding box, producing positions that are in the `-1.0 ... 1.0` range with correct aspect ratio. For example; to render arbitrary SVG paths in 3D, centred in world units.

This does not produce a copy of the path, but instead mutates it in place.

```js
var path = [ [x1, y1], [x2, y2], ... ]

//normalize path to -1.0 .. 1.0
normalize(path)

//render with webgl / canvas / etc
//...
```

## Usage

[![NPM](https://nodei.co/npm/normalize-path-scale.png)](https://nodei.co/npm/normalize-path-scale/)

### normalize(path[, bounds])

Normalizes the 2D `path` in place, scaling the points to `-1.0 .. 1.0` range. Maintains aspect ratio of the path. 

You can specify `bounds` for a custom bounding box:

```js
[ [minX, minY], [maxX, maxY] ]
```

Otherwise calculates the bounding box with [bound-points](https://github.com/mikolalysenko/bound-points).

Returns the specified `path`.

If the width or height of the bounding box is zero, this function returns early.

## Changes

- `2.0` changes the array in place, uses `bound-points`, returns early on zero size
- `1.0` a simple version that does not mutate the input

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/normalize-path-scale/blob/master/LICENSE.md) for details.

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