mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -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().
|
||||
}
|
||||
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
|
||||
// using clearRect and visa versa.
|
||||
if (canvas.width === width && canvas.height === height) {
|
||||
|
|
Loading…
Reference in a new issue