@@ -50,7 +50,7 @@ export interface IRenderingLayer {
5050 getY : ( ) => number ;
5151
5252 /**
53- * Resize the layer
53+ * Resize the layer
5454 */
5555 resize : ( width : number , height : number , resizeMethod : ResizeMethod ) => void ;
5656
@@ -114,14 +114,21 @@ export class RenderingLayer implements IRenderingLayer {
114114 * @param layerType Whether the layer elements will be updated on every frame
115115 * @param entity An optional, default first entity.
116116 */
117- constructor ( layerIndex : LayerIndex , layerType : LayerType , initialWidth ?: number , initialHeight ?: number , initialX : number = 0 , initialY : number = 0 ) {
117+ constructor (
118+ layerIndex : LayerIndex ,
119+ layerType : LayerType ,
120+ initialWidth ?: number ,
121+ initialHeight ?: number ,
122+ initialX : number = 0 ,
123+ initialY : number = 0 ,
124+ ) {
118125 this . layerIndex = layerIndex ;
119126 this . layerType = layerType ;
120127
121128 this . entities = [ ] ;
122129
123- this . width = initialWidth === undefined ? ( document . body . clientWidth + 1 ) : initialWidth ;
124- this . height = initialHeight === undefined ? ( document . body . clientHeight + 1 ) : initialHeight ;
130+ this . width = initialWidth === undefined ? document . body . clientWidth + 1 : initialWidth ;
131+ this . height = initialHeight === undefined ? document . body . clientHeight + 1 : initialHeight ;
125132 this . x = initialX ;
126133 this . y = initialY ;
127134
@@ -130,7 +137,7 @@ export class RenderingLayer implements IRenderingLayer {
130137 canvas . style . zIndex = `${ this . layerIndex } ` ;
131138 canvas . style . display = 'inline' ;
132139 document . body . appendChild ( canvas ) ;
133-
140+
134141 const context = canvas . getContext ( '2d' ) ;
135142 if ( ! context ) {
136143 throw new Error ( 'Could not initialize canvas 2D context.' ) ;
@@ -143,14 +150,14 @@ export class RenderingLayer implements IRenderingLayer {
143150
144151 /**
145152 * Change the size of the layer.
146- * @param newWidth The new width of the layer
153+ * @param newWidth The new width of the layer
147154 * @param newHeight The new height of the layer
148155 * @param resizeMethod How should we resize the layer: from the center, or from the top-left?
149156 */
150157 resize ( newWidth : number , newHeight : number , resizeMethod : ResizeMethod = ResizeMethod . FROM_ORIGIN ) {
151158 let xOffset = 0 ;
152159 let yOffset = 0 ;
153- if ( resizeMethod === ResizeMethod . FROM_CENTER ) {
160+ if ( resizeMethod === ResizeMethod . FROM_CENTER ) {
154161 xOffset = ( this . width - newWidth ) / 2 ;
155162 yOffset = ( this . height - newHeight ) / 2 ;
156163 }
@@ -173,7 +180,7 @@ export class RenderingLayer implements IRenderingLayer {
173180 this . x = newX ;
174181 this . y = newY ;
175182
176- if ( ! this . _isLayerWithinBounds ( ) ) {
183+ if ( ! this . _isLayerWithinBounds ( ) ) {
177184 throw new Error ( 'Cannot position and resize a layer outside of document body.' ) ;
178185 }
179186
@@ -295,10 +302,10 @@ export class RenderingLayer implements IRenderingLayer {
295302 */
296303 private _isLayerWithinBounds ( ) {
297304 return (
298- ( ( this . width + this . x ) > document . body . clientWidth ) ||
299- ( ( this . height + this . y ) > document . body . clientHeight ) ||
300- ( this . x < 0 ) ||
301- ( this . y < 0 )
305+ this . width + this . x > document . body . clientWidth ||
306+ this . height + this . y > document . body . clientHeight ||
307+ this . x < 0 ||
308+ this . y < 0
302309 ) ;
303310 }
304311}
0 commit comments