Skewing with pixijs
HTML
<script src="https://cdn.rawgit.com/GoodBoyDigital/pixi.js/v2.2.8/bin/pixi.js"></script>
<body>
<div id="panel"></div>
</body>
JavaScript
Kinetic = {};
Kinetic.Transform = function (m) {
this.m = (m && m.slice()) || [1, 0, 0, 1, 0, 0];
};
Kinetic.Transform.prototype = {
/**
* Copy Kinetic.Transform object
* @method
* @memberof Kinetic.Transform.prototype
* @returns {Kinetic.Transform}
*/
copy: function () {
return new Kinetic.Transform(this.m);
},
/**
* Transform point
* @method
* @memberof Kinetic.Transform.prototype
* @param {Object} 2D point(x, y)
* @returns {Object} 2D point(x, y)
*/
point: function (p) {
var m = this.m;
return {
x: m[0] * p.x + m[2] * p.y + m[4],
y: m[1] * p.x + m[3] * p.y + m[5]
};
},
/**
* Apply translation
* @method
* @memberof Kinetic.Transform.prototype
* @param {Number} x
* @param {Number} y
* @returns {Kinetic.Transform}
*/
translate: function (x, y) {
this.m[4] += this.m[0] * x + this.m[2] * y;
this.m[5] += this.m[1] * x + this.m[3] * y;
return this;
},
/**
* Apply scale
* @method
* @memberof Kinetic.Transform.prototype
* @param {Number} sx
* @param {Number} sy
* @returns {Kinetic.Transform}
*/
scale: function (sx, sy) {
this.m[0] *= sx;
this.m[1] *= sx;
this.m[2] *= sy;
this.m[3] *= sy;
return this;
},
/**
* Apply rotation
* @method
* @memberof Kinetic.Transform.prototype
* @param {Number} rad Angle in radians
* @returns {Kinetic.Transform}
*/
rotate: function (rad) {
var c = Math.cos(rad);
var s = Math.sin(rad);
var m11 = this.m[0] * c + this.m[2] * s;
var m12 = this.m[1] * c + this.m[3] * s;
var m21 = this.m[0] * -s + this.m[2] * c;
var m22 = this.m[1] * -s + this.m[3] * c;
this.m[0] = m11;
this.m[1] = m12;
this.m[2] = m21;
this.m[3] = m22;
return...