0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-30 10:20:52 -05:00

Ensure passed canvas abides by render options

Engine.create takes a canvas element or creates a new canvas using the
given options. While the properties width and height in options do apply
to the created canvas, they do not apply to the passed canvas. These set
options are under render.canvas, render.options.width and
render.options.height. This issue was fixed by setting the canvas width
and height only when a canvas element is directly provided.
This commit is contained in:
Schahriar SaffarShargh 2015-11-09 02:21:05 -08:00
parent e698b6b5be
commit 0b51dd67c5

View file

@ -64,6 +64,10 @@ var Grid = require('../collision/Grid');
var render = Common.extend(defaults, options);
if(render.canvas) {
render.canvas.width = render.options.width || render.canvas.width;
render.canvas.height = render.options.height || render.canvas.height;
}
render.canvas = render.canvas || _createCanvas(render.options.width, render.options.height);
render.context = render.canvas.getContext('2d');
render.textures = {};