Comparing version 1.0.2 to 1.1.0
@@ -8,10 +8,7 @@ module.exports = function createCanvas2D(opt) { | ||
canvas.height = opt.height | ||
if (typeof canvas.getContext !== 'function') | ||
throw new Error('canvas.getContext() not supported') | ||
try { | ||
return canvas.getContext('2d', opt) | ||
return canvas.getContext('2d', opt) || null | ||
} catch (e) { | ||
throw new Error('could not get 2D context: ' + e) | ||
return null | ||
} | ||
} |
{ | ||
"name": "2d-context", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "grabs a new 2d canvas context", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# 2d-context | ||
Creates a new canvas with a 2D context, returning the context. | ||
Grabs a CanvasRenderingContext2D, returning null if it doesn't exist. Similar to [webgl-context](https://nodei.co/npm/webgl-context/). | ||
@@ -29,3 +29,3 @@ ```js | ||
Creates a new canvas with optional parameters: | ||
Gets a new canvas context with optional parameters: | ||
@@ -32,0 +32,0 @@ - `canvas` a canvas element to use, otherwise creates a new element |
2264
12