Class ImageLibrary

Library of pre-loaded images.

Constructors

Methods

Constructors

  • Make a new image library, loading images from the filesystem (running in Node.js) or from URLs (running in a web browser).

    Parameters

    • dirname: "img"

      directory containing images, relative to the current folder (Node.js) or URL (web); must be "img"

    • Rest ...filenames: string[]

      images to load from the directory, e.g. "boromir.jpg"; names must be unique

    Returns ImageLibrary

Methods

  • Get an image from this library by name.

    Parameters

    • name: string

      image base filename, e.g. "boromir.jpg"

    Returns Image

    fully-loaded Image (so its dimensions and pixels are immediately available for use)

    Throws

    Error if no image by that name is in this library

Generated using TypeDoc