Skip to content

Commit

Permalink
Ensure passed canvas abides by render options
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
schahriar committed Nov 9, 2015
1 parent e698b6b commit 0b51dd6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/render/Render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down

0 comments on commit 0b51dd6

Please sign in to comment.