1.5.4 • Published 7 months ago

@types/canvas-fit v1.5.4

Weekly downloads
426
License
MIT
Repository
github
Last release
7 months ago

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

// Type definitions for canvas-fit 1.5
// Project: https://github.com/hughsk/canvas-fit
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/**
 * 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: Thu, 08 Jul 2021 00:35:50 GMT
  • Dependencies: none
  • Global values: none

Credits

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