https://github.com/dy/parse-rect
Return rectangle object from any possible rect-like argument
https://github.com/dy/parse-rect
Last synced: about 1 year ago
JSON representation
Return rectangle object from any possible rect-like argument
- Host: GitHub
- URL: https://github.com/dy/parse-rect
- Owner: dy
- License: mit
- Created: 2018-02-12T21:53:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-03T21:59:38.000Z (about 8 years ago)
- Last Synced: 2025-03-14T08:39:50.305Z (over 1 year ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# parse-rect [](http://github.com/badges/stability-badges) [](https://travis-ci.org/dy/parse-rect)
Take any rectangle-like argument and return rectangle values.
[](https://npmjs.org/package/parse-rect/)
```js
const parseRect = require('parse-rect')
// {x: 10, y: 20, width: 90, height: 80}
parseRect('10 20 100 100')
parseRect(10, 20, 100, 100)
parseRect([10, 20, 100, 100])
parseRect({ x: 10, y: 20, width: 90, height: 80 })
parseRect({ x: 10, y: 20, w: 90, h: 80 })
parseRect({ l: 10, t: 20, r: 100, b: 100 })
parseRect({ left: 10, top: 20, right: 100, bottom: 100 })
// {x: 0, y: 0, width: 90, height: 80}
parseRect({ width: 90, height: 80 })
parseRect([ 90, 80 ])
// {x: 0, y: 0, width: 90, height: 90}
parseRect(90)
parseRect([90])
```
## License
(c) 2018 Dmitry Yv. MIT License