@kayahr/wastelib
    Preparing search index...

    Interface ToCanvas

    Interface for classes which provide a toCanvas method to convert an image into a canvas.

    interface ToCanvas {
        toCanvas<T extends CanvasLike>(canvas: T): T;
    }

    Implemented by

    Index

    Methods

    Methods

    • Resets the given canvas to the image size and fills the canvas with the image. This does not create a new canvas so any canvas implementation can be used and existing canvas objects can be re-used.

      In a browser you do this:

      const canvas = image.toCanvas(document.createElement("canvas"))`;
      

      In Node.js (with node-canvas) you do this:

      import { createCanvas} from "canvas";

      const canvas = image.toCanvas(createCanvas());

      Type Parameters

      Parameters

      • canvas: T

        The canvas to reset and fill.

      Returns T

      The passed canvas for method chaining.