Library to generate complex matrixes to be used with CSS3 transforms. You can individually set/adjust/animate each of the four points of an element. Supports AMD.
The easiest way to install and stay up to date with Distort is through Bower:
bower install distort --save
// Height and Width are need to calcuate matrix
var distort = new Distort({
width: 100, // Required
height: 100, // Required
// Or
$el: $('.element'), // Or you can specify a jQuery element
// (Optional) Transform Origin - Defaults to center
offset: {
x: '0%' || '0px', // Accepts 'px' or '%'
y: '0%' || '0px',
}
});
// Relative
distort.topRight.x += 100;
distort.topRight.y += 100;
// Absolute
distort.bottomRight.x = 50;
distort.bottomRight.y = 50;
// Optionally check if the matrix was successfully calculated
if(distort.isValid) {
// Using jQuery for convenience
$('#image').css({
'transform' : distort.toString()
});
}
Forked from edankwan/PerspectiveTransform.js
The original PerspectiveTransform.js is created by Israel Pastrana http://www.is-real.net/experiments/css3/wonder-webkit/js/real/display/PerspectiveTransform.js
Matrix Libraries from a Java port of JAMA: A Java Matrix Package, http://math.nist.gov/javanumerics/jama/ Developed by Dr Peter Coxhead: http://www.cs.bham.ac.uk/~pxc/ Available here: http://www.cs.bham.ac.uk/~pxc/js/
I simply removed some irrelevant variables and functions and merge everything into a smaller function. I also added some error checking functions and bug fixing things.
Distort is open-sourced software licensed under the MIT license
- v1.0.2-alpha - Refactoring
- v1.0.1-alpha - Minor bug fixes
- v1.0.0-alpha - Initial Release