Options
All
  • Public
  • Public/Protected
  • All
Menu

Module image-library

Index

Functions

  • addImageFromFile(pathname: string): void
  • Add a new image to the library, running in Node.js.

    Parameters

    • pathname: string

      pathname of image to load, relative to caller's current folder (e.g. "img/boromir.jpg")

    Returns void

  • addImageFromWeb(pathname: string): void
  • Add a new image to the library, running in the Web browser.

    Parameters

    • pathname: string

      pathname of image to load, relative to caller's current URL (e.g. "img/boromir.jpg")

    Returns void

  • createCanvas(width: number, height: number, type?: "pdf" | "svg"): Canvas
  • Creates a Canvas instance. This function works in both Node.js and Web browsers, where there is no Canvas constructor.

    Parameters

    • width: number
    • height: number
    • Optional type: "pdf" | "svg"

      Optionally specify to create a PDF or SVG canvas. Defaults to an image canvas.

    Returns Canvas

  • getImage(name: string): Image
  • Get an image from the library by name.

    throws

    Error if no image by that name exists in the library

    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)

  • saveImageToFile(dataUrl: string, filename: string): void
  • Writes an image in PNG format to a file, running in Node.js.

    Parameters

    • dataUrl: string

      data: URL containing image data

    • filename: string

      filename to write image to

    Returns void

Generated using TypeDoc