@@ -56,25 +56,15 @@ var Phaser;
5656 this . canvas = document . createElement ( 'canvas' ) ;
5757 this . canvas . width = width ;
5858 this . canvas . height = height ;
59+ this . context = this . canvas . getContext ( '2d' ) ;
5960
60- if ( ( parent !== '' || parent !== null ) && document . getElementById ( parent ) ) {
61- document . getElementById ( parent ) . appendChild ( this . canvas ) ;
62- document . getElementById ( parent ) . style . overflow = 'hidden' ;
63- } else {
64- document . body . appendChild ( this . canvas ) ;
65- }
61+ Phaser . CanvasUtils . addToDOM ( this . canvas , parent , true ) ;
62+ Phaser . CanvasUtils . setTouchAction ( this . canvas ) ;
6663
67- // Consume default actions on the canvas
68- this . canvas . style . msTouchAction = 'none' ;
69- this . canvas . style [ 'ms-touch-action' ] = 'none' ;
70- this . canvas . style [ 'touch-action' ] = 'none' ;
71- this . canvas . style . backgroundColor = 'rgb(0,0,0)' ;
7264 this . canvas . oncontextmenu = function ( event ) {
7365 event . preventDefault ( ) ;
7466 } ;
7567
76- this . context = this . canvas . getContext ( '2d' ) ;
77-
7868 this . css3 = new Phaser . Display . CSS3Filters ( this . canvas ) ;
7969
8070 this . scaleMode = Phaser . StageScaleMode . NO_SCALE ;
@@ -125,7 +115,7 @@ var Phaser;
125115
126116 if ( this . clear || ( this . game . paused && this . disablePauseScreen == false ) ) {
127117 if ( this . game . device . patchAndroidClearRectBug ) {
128- this . context . fillStyle = 'rgb(0,0,0)' ;
118+ this . context . fillStyle = this . _backgroundColor ;
129119 this . context . fillRect ( 0 , 0 , this . width , this . height ) ;
130120 } else {
131121 this . context . clearRect ( 0 , 0 , this . width , this . height ) ;
@@ -185,13 +175,6 @@ var Phaser;
185175 }
186176 } ;
187177
188- Stage . prototype . setImageRenderingCrisp = function ( ) {
189- this . canvas . style [ 'image-rendering' ] = 'crisp-edges' ;
190- this . canvas . style [ 'image-rendering' ] = '-moz-crisp-edges' ;
191- this . canvas . style [ 'image-rendering' ] = '-webkit-optimize-contrast' ;
192- this . canvas . style [ '-ms-interpolation-mode' ] = 'nearest-neighbor' ;
193- } ;
194-
195178 Stage . prototype . pauseGame = function ( ) {
196179 this . game . paused = true ;
197180
@@ -250,7 +233,7 @@ var Phaser;
250233 this . context . fillStyle = this . fillStyle ;
251234
252235 if ( this . game . device . patchAndroidClearRectBug ) {
253- this . context . fillStyle = 'rgb(0,0,0)' ;
236+ this . context . fillStyle = this . _backgroundColor ;
254237 this . context . fillRect ( 0 , 0 , this . width , this . height ) ;
255238 } else {
256239 this . context . clearRect ( 0 , 0 , this . width , this . height ) ;
0 commit comments