File tree Expand file tree Collapse file tree 1 file changed +9
-17
lines changed
Expand file tree Collapse file tree 1 file changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -384,27 +384,19 @@ export class Actor implements SceneObject {
384384 // Create dummy canvas to get pixel data of the actor sprite
385385
386386 let canvas = document . getElementById ( "auxillary_canvas" ) as HTMLCanvasElement ;
387- let greatestXWidth = 0 ; // The width of the actor w/ the greatest x.
388- let greatestYHeight = 0 ; // The height of the actor w/ the greatest y.
389- let greatestX = 0 ;
390- let greatestY = 0 ;
387+ let maxRight = 0 ;
388+ let maxBottom = 0 ;
391389 let greatestZ = 0 ;
392390
393391 options . actors . forEach ( ( actor : Actor ) => {
394- if ( actor . getX ( ) > greatestX ) {
395- greatestX = actor . getX ( ) ;
396- greatestXWidth = actor . getWidth ( ) ;
397- }
398- if ( actor . getY ( ) > greatestY ) {
399- greatestY = actor . getY ( ) ;
400- greatestYHeight = actor . getHeight ( ) ;
401- }
402- if ( actor . getZIndex ( ) > greatestZ ) {
403- greatestZ = actor . getZIndex ( ) ;
404- }
392+ const right = actor . getX ( ) + actor . getWidth ( ) ;
393+ const bottom = actor . getY ( ) + actor . getHeight ( ) ;
394+ if ( right > maxRight ) maxRight = right ;
395+ if ( bottom > maxBottom ) maxBottom = bottom ;
396+ if ( actor . getZIndex ( ) > greatestZ ) greatestZ = actor . getZIndex ( ) ;
405397 } ) ;
406- canvas . width = options . canvasWidth || greatestX + greatestXWidth ;
407- canvas . height = options . canvasHeight || greatestY + greatestYHeight ;
398+ canvas . width = options . canvasWidth || maxRight ;
399+ canvas . height = options . canvasHeight || maxBottom ;
408400
409401 const ctx = canvas . getContext ( "2d" ) ;
410402
You can’t perform that action at this time.
0 commit comments