mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Canvas: Throw an error if a canvas cannot provide a 2D context.
This commit is contained in:
parent
8c60931200
commit
90e1cf8f5e
1 changed files with 4 additions and 0 deletions
|
@ -29,6 +29,10 @@ var CanvasProvider = {
|
||||||
clear = false; // It's already cleared through createElement().
|
clear = false; // It's already cleared through createElement().
|
||||||
}
|
}
|
||||||
var ctx = canvas.getContext('2d');
|
var ctx = canvas.getContext('2d');
|
||||||
|
if (!ctx) {
|
||||||
|
throw new Error('Canvas ' + canvas +
|
||||||
|
' is unable toprovide a 2D context.');
|
||||||
|
}
|
||||||
// If they are not the same size, we don't need to clear them
|
// If they are not the same size, we don't need to clear them
|
||||||
// using clearRect and visa versa.
|
// using clearRect and visa versa.
|
||||||
if (canvas.width === width && canvas.height === height) {
|
if (canvas.width === width && canvas.height === height) {
|
||||||
|
|
Loading…
Reference in a new issue