@types/canvas-fit
TypeScript icon, indicating that this package has built-in type declarations

1.5.4 • Public • Published

Installation

npm install --save @types/canvas-fit

Summary

This package contains type definitions for canvas-fit (https://github.com/hughsk/canvas-fit).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/canvas-fit.

index.d.ts

/**
 * Creates a resize function for your canvas element. Calling this function will resize the canvas to fit its parent element.
 */
declare function fit(
    canvas: HTMLCanvasElement | SVGElement,
    parent?: EventTarget | Document | HTMLElement,
    scale?: string | number,
): resize;

interface resize {
    (this: any, ev: any): any;
    /**
     * Dynamically change the canvas' target scale.
     * Note that you still need to manually trigger a resize after doing this.
     */
    scale: number;
    /**
     * Dynamically change the canvas' target scale.
     * Note that you still need to manually trigger a resize after doing this.
     * Instead of filling a given element, explicitly set the width and height of the canvas.
     * Note that this value will still be scaled up according to resize.scale
     */
    parent?: Element | (() => [number, number]) | undefined;
}

/**
 * Small module for fitting a canvas element within the bounds of its parent.
 * Useful, for example, for making a canvas fill the screen. Works with SVG elements too!
 */
export = fit;

Additional Details

  • Last updated: Mon, 06 Nov 2023 22:41:05 GMT
  • Dependencies: none

Credits

These definitions were written by Piotr Błażejewicz.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @types/canvas-fit

      Weekly Downloads

      111

      Version

      1.5.4

      License

      MIT

      Unpacked Size

      4.74 kB

      Total Files

      5

      Last publish

      Collaborators

      • types