import { Canvas } from "../canvas" ; import { Loader } from "../loader" ; import { Layer } from "./layers" ; export class Background extends Layer { private backgroundImage : ImageBitmap ; private backgroundImageURL : string ; constructor ( ) ; constructor ( imageURL ? ) { super ( ) ; if ( imageURL != null ) { this . BackgroundImage = imageURL ; } } set BackgroundImage ( imageURL ) { if ( imageURL !== this . backgroundImageURL ) { this . backgroundImageURL = imageURL ; Loader . LoadImage ( imageURL ) . then ( image => { this . backgroundImage = image ; } ) ; } } Draw ( canvas ) { if ( this . backgroundImage != null ) { canvas . DrawBackgroundImage ( this . backgroundImage ) ; } } }