Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.
/ fisheye.js Public archive

A javascript library for applying radial lens distortion to images using WebGL.

License

Notifications You must be signed in to change notification settings

ericleong/fisheye.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

fisheye.js

fisheye.js is a javascript library for drawing images to the canvas with simple radial lens distortion using WebGL.

Visit ericleong.github.io/fisheye.js for a demo.

install

For those using bower

$ bower install fisheye.js

usage

Make sure to include the library!

<script src="fisheye.js"></script>

Use it like this:

var fisheye = new Fisheye(<canvas>);

fisheye.setDistortion(<red value>, <green value>, <blue value>);
fisheye.draw(<image>);

api

var fisheye = new Fisheye(<canvas>);

<canvas> is an HTMLCanvasElement where the distorted image should be displayed.

fisheye.setDistortion(<red value>, <green value>, <blue value>);

Each <value> is a number, use a positive value for barrel distortion and a negative value for pincushion distortion. If only the first argument is supplied, it is used for all colors. Use different amounts of distortion for each color channel to simulate chromatic aberration.

fisheye.draw(<image>);

<image> is either an HTMLCanvasElement or an HTMLImageElement. It is the undistorted image.

fisheye.setViewport(<width>, <height>);

If the canvas size is changed, update the viewport size with this method.

fisheye.clear();

When drawing a new image, you may need to call clear() to clear the existing canvas.

About

A javascript library for applying radial lens distortion to images using WebGL.

Resources

License

Stars

Watchers

Forks

Packages