pencil.js
Version:
Nice modular interactive 2D drawing library.
96 lines (95 loc) • 2.74 kB
TypeScript
/**
* Image class
* <br><img src="./media/examples/image.png" alt="image demo"/>
* @class
* @extends {module:Rectangle}
*/
export default class Image {
/**
* @inheritDoc
* @param {Object} definition - Image definition
* @return {Image}
*/
static from(definition: any): Image;
/**
* Promise to load an image file.
* @param {String|Array<String>} url - Link or an array of links to image files
* @return {Promise<HTMLImageElement>}
*/
static load(url: string | Array<string>): Promise<HTMLImageElement>;
/**
* @typedef {Object} ImageOptions
* @extends ComponentOptions
* @prop {String|Color} [fill=null] - Color used as background
* @prop {String|Color} [tint=null] - Multiply the image pixels with a color
* @prop {String} [description=""] - Description of the image (can be used to for better accessibility)
*/
/**
* @type {ImageOptions}
*/
static get defaultOptions(): any;
/**
* Image constructor
* @param {PositionDefinition} positionDefinition - Top-left corner of the image
* @param {String|Image|HTMLImageElement} source - Link to an image file, another Image instance or the image file itself
* @param {ComponentOptions} [options] - Drawing options
*/
constructor(positionDefinition: PositionDefinition, source: string | Image | HTMLImageElement, options?: ComponentOptions);
/**
* @type {HTMLImageElement}
*/
file: HTMLImageElement;
/**
* @type {Boolean}
*/
isLoaded: boolean;
/**
* Change the image URL
* @param {String|Image|HTMLImageElement} source - Link to an image file, another Image instance or the image file itself
*/
set url(source: string | HTMLImageElement | Image);
/**
* Get the image URL
* @return {String}
*/
get url(): string;
width: any;
height: any;
/**
* Draw it on a context
* @param {CanvasRenderingContext2D} ctx - Drawing context
* @return {Image} Itself
*/
makePath(ctx: CanvasRenderingContext2D): Image;
path: Path2D;
/**
* Draw the image itself
* @param {CanvasRenderingContext2D} ctx - Drawing context
* @return {Image} Itself
*/
draw(ctx: CanvasRenderingContext2D): Image;
/**
* @inheritDoc
*/
isHover(...args: any[]): any;
/**
* @inheritDoc
*/
toJSON(): any;
/**
* @type {String}
* @private
*/
private [urlKey];
/**
* @type {{ tint: String, cache: OffScreenCanvas }}
* @private
*/
private [offscreenKey];
}
/**
* @module Image
*/
declare const urlKey: unique symbol;
declare const offscreenKey: unique symbol;
export {};