Merge pull request #7 from amadeus/master
Allowing Renderer's to accept a pre-made canvas/view
This commit is contained in:
commit
b022051124
3 changed files with 10 additions and 7 deletions
|
@ -8,8 +8,9 @@
|
||||||
* @class CanvasRenderer
|
* @class CanvasRenderer
|
||||||
* @param width {Number} the width of the canvas view
|
* @param width {Number} the width of the canvas view
|
||||||
* @param height {Number} the height of the canvas view
|
* @param height {Number} the height of the canvas view
|
||||||
|
* @param view {Canvas} the canvas to use as a view, optional
|
||||||
*/
|
*/
|
||||||
PIXI.CanvasRenderer = function(width, height)
|
PIXI.CanvasRenderer = function(width, height, view)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The width of the canvas view
|
* The width of the canvas view
|
||||||
|
@ -33,7 +34,7 @@ PIXI.CanvasRenderer = function(width, height)
|
||||||
* @property view
|
* @property view
|
||||||
* @type Canvas
|
* @type Canvas
|
||||||
*/
|
*/
|
||||||
this.view = document.createElement( 'canvas' );
|
this.view = view ? view : document.createElement( 'canvas' );
|
||||||
|
|
||||||
// hack to enable some hardware acceleration!
|
// hack to enable some hardware acceleration!
|
||||||
//this.view.style["transform"] = "translatez(0)";
|
//this.view.style["transform"] = "translatez(0)";
|
||||||
|
|
|
@ -13,13 +13,14 @@ PIXI._defaultFrame = new PIXI.Rectangle(0,0,1,1);
|
||||||
* @default 0
|
* @default 0
|
||||||
* @param height {Number} the height of the canvas view
|
* @param height {Number} the height of the canvas view
|
||||||
* @default 0
|
* @default 0
|
||||||
|
* @param view {Canvas} the canvas to use as a view, optional
|
||||||
*/
|
*/
|
||||||
PIXI.WebGLRenderer = function(width, height)
|
PIXI.WebGLRenderer = function(width, height, view)
|
||||||
{
|
{
|
||||||
this.width = width ? width : 800;
|
this.width = width ? width : 800;
|
||||||
this.height = height ? height : 600;
|
this.height = height ? height : 600;
|
||||||
|
|
||||||
this.view = document.createElement( 'canvas' );
|
this.view = view ? view : document.createElement( 'canvas' );
|
||||||
this.view.width = this.width;
|
this.view.width = this.width;
|
||||||
this.view.height = this.height;
|
this.view.height = this.height;
|
||||||
this.view.background = "#FF0000";
|
this.view.background = "#FF0000";
|
||||||
|
|
|
@ -9,8 +9,9 @@
|
||||||
* @static
|
* @static
|
||||||
* @param width {Number} the width of the renderers view
|
* @param width {Number} the width of the renderers view
|
||||||
* @param height {Number} the height of the renderers view
|
* @param height {Number} the height of the renderers view
|
||||||
|
* @param view {Canvas} the canvas to use as a view, optional
|
||||||
*/
|
*/
|
||||||
PIXI.autoDetectRenderer = function(width, height)
|
PIXI.autoDetectRenderer = function(width, height, view)
|
||||||
{
|
{
|
||||||
if(!width)width = 800;
|
if(!width)width = 800;
|
||||||
if(!height)height = 600;
|
if(!height)height = 600;
|
||||||
|
@ -21,10 +22,10 @@ PIXI.autoDetectRenderer = function(width, height)
|
||||||
//console.log(webgl);
|
//console.log(webgl);
|
||||||
if( webgl )
|
if( webgl )
|
||||||
{
|
{
|
||||||
return new PIXI.WebGLRenderer(width, height)
|
return new PIXI.WebGLRenderer(width, height, view)
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PIXI.CanvasRenderer(width, height);
|
return new PIXI.CanvasRenderer(width, height, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue