• Stars
    star
    286
  • Rank 144,690 (Top 3 %)
  • Language
    JavaScript
  • Created over 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Javascript Class to do the CSS 3D transformation by 4 destination points

PerspectiveTransform

This is an extremely useful class for advanced CSS 3d animation. You can set the x, y point of the corners of a DOM element and do need to think about the complicated Matrix formula behind it.

alt text

Demo

Usage

    // create PerspectiveTransfrom
    var transform = new PerspectiveTransform(elem, width, height, useBackFacing);

    // the properties represent the 4 corners are "topLeft", "topRight", "bottomLeft" and "bottomRight"
    transform.bottomRight.x = 200;
    transform.bottomRight.y = 200;

    // check the polygon error before updating
    if(transform.checkError()==0){
        transform.update(); // update the perspective transform
        elem.style.display = "block"; // show the element
    }else{
        elem.style.display = "none"; // hide the element
    }

Firefox on retina screen fix

PerspectiveTransform.useDPRFix = true; // put true if you need to apply this fix

window.onresize = function(){
    PerspectiveTransform.dpr = window.devicePixelRatio; // update the dpr
    transform.update(); // update the PerspectiveTransform instance
}

Credit

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.

More Repositories

1

penis.js

JavaScript
1,311
star
2

The-Spirit

WebGL Experiment
JavaScript
1,091
star
3

hyper-mix

JavaScript
228
star
4

Jesus.js

Not sure what will it do yet. But it just sounds like a really powerful library no matter what it really does.
JavaScript
212
star
5

Constraint

JavaScript
119
star
6

vagina.js

JavaScript
108
star
7

Icicle-Bubbles

JavaScript
89
star
8

touch-leap-motion

JavaScript
83
star
9

SMASHING-Mega-Scene

JavaScript
64
star
10

quick-loader

quick-loader is an asset loader that loads everything
JavaScript
52
star
11

pixi-custom

A flexible(sort of) way to expose the possibility of using vertex shader in PIXI 3.0
JavaScript
36
star
12

zen-painting

JavaScript
15
star
13

Everyday-Experiment

14
star
14

min-signal

A mini version of signal in Javascript. It supports priority and additional prefixed/suffixed arguments.
JavaScript
14
star
15

EKTweener.js

Just a simple Tweener for JS
JavaScript
11
star
16

Exec-Parser-Sublime-Plugin

A plugin that allow users to add custom python parser commands for paste command and duplicate line command.
Python
7
star
17

snowy-snow-globe

**Snowy Snow Globe** is part of the Christmas Experiments 2015.
JavaScript
5
star
18

localize-your-website-using-google-sheets

JavaScript
5
star
19

advanced_frontend_development_exercises

exercises for my meetup talk about advanced frontend development
JavaScript
4
star
20

asshole.io

Source codes of asshole.io
4
star
21

christmas-card-to-everyone

A Christmas Experiment for 2014
JavaScript
4
star
22

Bum-Bum-Mapping

An old experiment I did using bump mapping shit
3
star
23

ring-loader.codepen.io

A silly way not using any new HTML5/CSS3 to do the old school ring style preloader.
JavaScript
3
star
24

three.js-amdifier

A tool to turn threejs sources into amd modules
JavaScript
2
star
25

tiny-panorma

1
star