2012-09-19 22:43:39 +00:00
|
|
|
(function () {
|
2013-08-10 10:11:16 +00:00
|
|
|
var ns = $.namespace("pskl");
|
2012-09-19 22:43:39 +00:00
|
|
|
|
2013-08-10 10:11:16 +00:00
|
|
|
ns.CanvasUtils = {
|
|
|
|
createCanvas : function (width, height, classList) {
|
|
|
|
var canvas = document.createElement("canvas");
|
|
|
|
canvas.setAttribute("width", width);
|
|
|
|
canvas.setAttribute("height", height);
|
2012-09-19 22:43:39 +00:00
|
|
|
|
2013-08-10 10:11:16 +00:00
|
|
|
if (typeof classList == "string") {
|
|
|
|
classList = [classList];
|
|
|
|
}
|
|
|
|
if (Array.isArray(classList)) {
|
|
|
|
for (var i = 0 ; i < classList.length ; i++) {
|
|
|
|
canvas.classList.add(classList[i]);
|
|
|
|
}
|
|
|
|
}
|
2013-10-29 21:16:39 +00:00
|
|
|
|
2013-08-10 10:11:16 +00:00
|
|
|
return canvas;
|
2013-10-29 21:16:39 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
disableImageSmoothing : function (canvas) {
|
|
|
|
var context = canvas.getContext('2d');
|
|
|
|
context.imageSmoothingEnabled = false;
|
|
|
|
context.mozImageSmoothingEnabled = false;
|
|
|
|
context.oImageSmoothingEnabled = false;
|
|
|
|
context.webkitImageSmoothingEnabled = false;
|
|
|
|
context.msImageSmoothingEnabled = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
clear : function (canvas) {
|
|
|
|
if (canvas) {
|
|
|
|
canvas.getContext("2d").clearRect(0, 0, canvas.width, canvas.height);
|
|
|
|
}
|
2013-08-10 10:11:16 +00:00
|
|
|
}
|
|
|
|
};
|
2012-09-19 22:43:39 +00:00
|
|
|
})();
|