mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
parent
013698bc29
commit
fc0583975d
1 changed files with 30 additions and 0 deletions
|
@ -185,6 +185,36 @@ var Mouse = require('../core/Mouse');
|
||||||
canvas.style.height = options.height + 'px';
|
canvas.style.height = options.height + 'px';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the render `width` and `height`.
|
||||||
|
*
|
||||||
|
* Updates the canvas accounting for `render.options.pixelRatio`.
|
||||||
|
*
|
||||||
|
* Updates the bottom right render bound `render.bounds.max` relative to the provided `width` and `height`.
|
||||||
|
* The top left render bound `render.bounds.min` isn't changed.
|
||||||
|
*
|
||||||
|
* Follow this call with `Render.lookAt` if you need to change the render bounds.
|
||||||
|
*
|
||||||
|
* See also `Render.setPixelRatio`.
|
||||||
|
* @method setSize
|
||||||
|
* @param {render} render
|
||||||
|
* @param {number} width The width (in CSS pixels)
|
||||||
|
* @param {number} height The height (in CSS pixels)
|
||||||
|
*/
|
||||||
|
Render.setSize = function(render, width, height) {
|
||||||
|
render.options.width = width;
|
||||||
|
render.options.height = height;
|
||||||
|
render.bounds.max.x = render.bounds.min.x + width;
|
||||||
|
render.bounds.max.y = render.bounds.min.y + height;
|
||||||
|
|
||||||
|
if (render.options.pixelRatio !== 1) {
|
||||||
|
Render.setPixelRatio(render, render.options.pixelRatio);
|
||||||
|
} else {
|
||||||
|
render.canvas.width = width;
|
||||||
|
render.canvas.height = height;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Positions and sizes the viewport around the given object bounds.
|
* Positions and sizes the viewport around the given object bounds.
|
||||||
* Objects must have at least one of the following properties:
|
* Objects must have at least one of the following properties:
|
||||||
|
|
Loading…
Reference in a new issue