Add ol.dom.createCanvasContext2D function

This commit is contained in:
Frederic Junod
2014-04-01 16:25:02 +02:00
parent 0b21c6bea7
commit 55de0a54b9
12 changed files with 63 additions and 118 deletions

View File

@@ -11,6 +11,24 @@ goog.require('goog.userAgent');
goog.require('goog.vec.Mat4');
/**
* Create an html canvas element and returns its 2d context.
* @param {number=} opt_width Canvas width.
* @param {number=} opt_height Canvas height.
* @return {CanvasRenderingContext2D}
*/
ol.dom.createCanvasContext2D = function(opt_width, opt_height) {
var canvas = goog.dom.createElement(goog.dom.TagName.CANVAS);
if (goog.isDef(opt_width)) {
canvas.width = opt_width;
}
if (goog.isDef(opt_height)) {
canvas.height = opt_height;
}
return canvas.getContext('2d');
};
/**
* @enum {boolean}
*/