Skip to content

Volst/change-perspective

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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]);

About

Very small JavaScript library for creating and applying perspective transforms

Resources

Stars

Watchers

Forks

Packages

No packages published