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

3.0.3 • Public • Published

Installation

npm install --save @types/cytoscape-canvas

Summary

This package contains type definitions for cytoscape-canvas (https://github.com/classcraft/cytoscape.js-canvas).

Details

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

index.d.ts

import cytoscape = require("cytoscape");

declare const cyCanvas: cytoscape.Ext;

export = cyCanvas;
export as namespace cyCanvas;

declare namespace cyCanvas {
    interface Options {
        /**
         * The z-index of the canvas.
         */
        zIndex?: number;
        /**
         * The pixel ratio of the canvas.
         */
        pixelRatio?: number;
    }

    interface CanvasInstance {
        /**
         * Return the generated canvas.
         */
        getCanvas: () => HTMLCanvasElement;

        /**
         * Set the context transform to match Cytoscape's zoom & pan.
         * Further drawing will be on model position.
         * @param ctx The canvas context.
         */
        setTransform: (ctx: CanvasRenderingContext2D) => void;

        /**
         * Reset the context transform.
         * Further drawing will be on rendered position.
         * @param ctx The canvas context.
         */
        resetTransform: (ctx: CanvasRenderingContext2D) => void;

        /**
         * Clear the entire canvas.
         * @param ctx The canvas context.
         */
        clear: (ctx: CanvasRenderingContext2D) => void;
    }
}

declare global {
    namespace cytoscape {
        interface Core {
            /*
             * Initialize the canvas according to the given options.
             */
            cyCanvas: (options?: cyCanvas.Options) => cyCanvas.CanvasInstance;
        }
    }
}

Additional Details

Credits

These definitions were written by Musa.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/cytoscape-canvas

Weekly Downloads

788

Version

3.0.3

License

MIT

Unpacked Size

5.54 kB

Total Files

5

Last publish

Collaborators

  • types