Class: ImageCache
Defined in: asset-loading/asset-caches/image-cache.ts:6
Class to manage the caching and loading of images.
Implements
AssetCache
<HTMLImageElement
>
Constructors
Constructor
new ImageCache():
ImageCache
Returns
ImageCache
Properties
assets
assets:
Map
<string
,HTMLImageElement
>
Defined in: asset-loading/asset-caches/image-cache.ts:7
A map of asset paths to their corresponding assets.
Implementation of
Methods
get()
get(
path
):HTMLImageElement
Defined in: asset-loading/asset-caches/image-cache.ts:15
Retrieves an asset from the cache.
Parameters
path
string
The path of the image to retrieve.
Returns
HTMLImageElement
The cached image element.
Throws
Will throw an error if the image is not found in the cache.
Implementation of
getOrLoad()
getOrLoad(
path
):Promise
<HTMLImageElement
>
Defined in: asset-loading/asset-caches/image-cache.ts:57
Retrieves an asset from the cache if it exists, otherwise loads and caches it.
Parameters
path
string
The path of the image to retrieve or load.
Returns
Promise
<HTMLImageElement
>
A promise that resolves to the image element.
Implementation of
load()
load(
path
):Promise
<void
>
Defined in: asset-loading/asset-caches/image-cache.ts:31
Loads an asset from the specified path and caches it.
Parameters
path
string
The path of the image to load.
Returns
Promise
<void
>
A promise that resolves when the image is loaded and cached.
Throws
Will throw an error if the image fails to load.