@@ -133,19 +133,30 @@ export default class TableCanvas extends SuperComponent<ITableCanvas>{
133133 for ( let i = 0 ; i < this . fogOfWarShapes . length ; i ++ ) {
134134 switch ( this . fogOfWarShapes [ i ] . type ) {
135135 case "poly" :
136- this . fogctx . beginPath ( ) ;
137- this . fogctx . moveTo ( this . fogOfWarShapes [ i ] . points [ 0 ] . x , this . fogOfWarShapes [ i ] . points [ 0 ] . y ) ;
138- for ( let p = 1 ; p < this . fogOfWarShapes [ i ] . points . length ; p ++ ) {
139- this . fogctx . lineTo ( this . fogOfWarShapes [ i ] . points [ p ] . x , this . fogOfWarShapes [ i ] . points [ p ] . y ) ;
136+ try {
137+ this . fogctx . beginPath ( ) ;
138+ this . fogctx . moveTo ( this . fogOfWarShapes [ i ] . points [ 0 ] . x , this . fogOfWarShapes [ i ] . points [ 0 ] . y ) ;
139+ for ( let p = 1 ; p < this . fogOfWarShapes [ i ] . points . length ; p ++ ) {
140+ this . fogctx . lineTo ( this . fogOfWarShapes [ i ] . points [ p ] . x , this . fogOfWarShapes [ i ] . points [ p ] . y ) ;
141+ }
142+ this . fogctx . closePath ( ) ;
143+ this . fogctx . fill ( ) ;
144+ } catch ( e ) {
145+ console . error ( "Render error:" , e ) ;
140146 }
141- this . fogctx . closePath ( ) ;
142- this . fogctx . fill ( ) ;
143147 break ;
144148 case "rect" :
145- const width = this . fogOfWarShapes [ i ] . points [ 1 ] . x - this . fogOfWarShapes [ i ] . points [ 0 ] . x ;
146- const height = this . fogOfWarShapes [ i ] . points [ 1 ] . y - this . fogOfWarShapes [ i ] . points [ 0 ] . y
147- this . fogctx . rect ( this . fogOfWarShapes [ i ] . points [ 0 ] . x , this . fogOfWarShapes [ i ] . points [ 0 ] . y , width , height ) ;
148- this . fogctx . fill ( ) ;
149+ try {
150+ const width = this . fogOfWarShapes [ i ] . points [ 1 ] . x - this . fogOfWarShapes [ i ] . points [ 0 ] . x ;
151+ const height = this . fogOfWarShapes [ i ] . points [ 1 ] . y - this . fogOfWarShapes [ i ] . points [ 0 ] . y
152+ this . fogctx . rect ( this . fogOfWarShapes [ i ] . points [ 0 ] . x , this . fogOfWarShapes [ i ] . points [ 0 ] . y , width , height ) ;
153+ this . fogctx . fill ( ) ;
154+ } catch ( e ) {
155+ console . error ( "Render error:" , e ) ;
156+ }
157+ break ;
158+ default :
159+ console . error ( "How did you get here?" ) ;
149160 break ;
150161 }
151162 }
@@ -244,28 +255,32 @@ export default class TableCanvas extends SuperComponent<ITableCanvas>{
244255
245256 if ( ! this . image ) return ;
246257
247- // Always draw map first
248- this . imgctx . drawImage (
249- this . image ,
250- 0 , 0 , this . w , this . h
251- ) ;
252-
253258 // Other
254259 this . renderGridLines ( ) ;
255260 this . renderFogOfWar ( ) ;
256-
261+
262+ // Always draw map first
257263 this . imgctx . drawImage (
258- this . gridCanvas ,
259- 0 , 0 ,
260- this . w , this . h
264+ this . image ,
265+ 0 , 0 , this . w , this . h
261266 ) ;
267+
268+ if ( this . renderGridLines ) {
269+ this . imgctx . drawImage (
270+ this . gridCanvas ,
271+ 0 , 0 ,
272+ this . w , this . h
273+ ) ;
274+ }
262275
263276 // Always draw fog last
264- this . imgctx . drawImage (
265- this . fogCanvas ,
266- 0 , 0 ,
267- this . w , this . h
268- ) ;
277+ if ( this . renderFogOfWar ) {
278+ this . imgctx . drawImage (
279+ this . fogCanvas ,
280+ 0 , 0 ,
281+ this . w , this . h
282+ ) ;
283+ }
269284 }
270285}
271286env . bind ( "table-canvas" , TableCanvas ) ;
0 commit comments