1.0.1 • Published 5 years ago

change-perspective v1.0.1

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

change-perspective

A very small JavaScript library (no dependencies!) for creating and applying perspective transforms. A perspective transform can easily be used to map one 2D quadrilateral to another, given the corner coordinates for the source and destination quadrilaterals.

Based on perspective-transform but refactored to use commonJS, provide TypeScript typings and remove a pesky console.log that bothered me in the code.

Install

npm install change-perspective

Usage

const changePerspective = require('change-perspecitve');

const srcCorners = [158, 64, 494, 69, 495, 404, 158, 404];
const dstCorners = [100, 500, 152, 564, 148, 604, 100, 560];
const transform = changePerspective(srcCorners, dstCorners);
const srcPt = [250, 120];
const dstPt = transform(srcPt[0], srcPt[1]);
1.0.1

5 years ago

1.0.0

5 years ago

0.0.0

5 years ago