Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cheapsteak/rect-zoom-transforms
Calculate the scaling and translations required to zoom and pan one rectangle to another rectangle within the first
https://github.com/cheapsteak/rect-zoom-transforms
Last synced: 21 days ago
JSON representation
Calculate the scaling and translations required to zoom and pan one rectangle to another rectangle within the first
- Host: GitHub
- URL: https://github.com/cheapsteak/rect-zoom-transforms
- Owner: cheapsteak
- Created: 2015-10-21T05:37:48.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-21T05:45:44.000Z (about 9 years ago)
- Last Synced: 2024-11-01T08:25:54.140Z (2 months ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rect-zoom-transforms
Calculate the scaling and translations required to zoom and pan from one rectangle to another rectangle within the first.
## Usage ##
```js
var rectZoomTransforms = require('rect-zoom-transforms');// originalRect and targetRect are expected to have the properties `x`, `y`, `width`, `height`.
rectZoomTransforms(originalRect, targetRect);
```Returns an object:
```js
{
scale: {
// x and y are numbers between 0 and 1
x,
y
},
translate: {
// x and y are numeric translation distances in pixels
x,
y,
// xPercent and yPercent are values between 0 and 100
xPercent,
yPercent
}
}
```## License ##
MIT