piskel/js/utils/CanvasUtils.js

22 lines
501 B
JavaScript
Raw Normal View History

(function () {
2013-05-27 21:42:53 +00:00
var ns = $.namespace("pskl");
2013-05-27 21:42:53 +00:00
ns.CanvasUtils = {
createCanvas : function (width, height, classList) {
var canvas = document.createElement("canvas");
canvas.setAttribute("width", width);
canvas.setAttribute("height", height);
if (typeof classList == "string") {
2013-05-27 21:42:53 +00:00
classList = [classList];
}
if (Array.isArray(classList)) {
for (var i = 0 ; i < classList.length ; i++) {
canvas.classList.add(classList[i]);
}
2013-05-27 21:42:53 +00:00
}
return canvas;
2013-05-27 21:42:53 +00:00
}
};
})();