add drawing tests to casper

This commit is contained in:
jdescottes
2014-08-22 00:37:35 +02:00
parent 1955d3f8f5
commit 56b1f421bc
15 changed files with 341 additions and 24 deletions

View File

@@ -26,6 +26,13 @@
return canvas;
},
createFromImage : function (image) {
var canvas = pskl.CanvasUtils.createCanvas(image.width, image.height);
var context = canvas.getContext('2d');
context.drawImage(image, 0, 0);
return canvas;
},
/**
* By default, all scaling operations on a Canvas 2D Context are performed using antialiasing.
* Resizing a 32x32 image to 320x320 will lead to a blurry output.

View File

@@ -14,13 +14,26 @@ jQuery.namespace = function() {
/**
* Need a polyfill for PhantomJS
*/
if (typeof Function.prototype.bind !== "function") {
Function.prototype.bind = function(scope) {
"use strict";
var _function = this;
return function() {
return _function.apply(scope, arguments);
};
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5
// internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var bindArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
fBound = function () {
var args = bindArgs.concat(Array.prototype.slice.call(arguments));
return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, args);
};
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
return fBound;
};
}