@inweb/markup
Version:
JavaScript 2D markups
93 lines (92 loc) • 2.77 kB
TypeScript
import { IMarkupObject } from "./IMarkupObject";
/**
* 2D markup Image object interface.
*/
export interface IMarkupImage extends IMarkupObject {
/**
* Returns the screen coordinates of the top-left point (position) of the image.
*/
getPosition(): {
x: number;
y: number;
};
/**
* Sets the screen coordinates of the top-left point (position) of the image.
*/
setPosition(x: number, y: number): void;
/**
* Returns the image source as a base64-encoded
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}.
*/
getSrc(): string;
/**
* Sets the image source. External image URL is not supported, only base64-encoded
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URLs}.
*
* @param src - Image source as base64-encoded string.
*/
setSrc(src: string): void;
/**
* Returns the width of the image. The original image is scaled to this width.
*/
getWidth(): number;
/**
* Sets the width of the image. The image height will be automatically updated to match its aspect
* ratio.
*/
setWidth(w: number): void;
/**
* Returns the height of the image. The original image is scaled to this height.
*/
getHeight(): number;
/**
* Sets the height of the image. The image width will be automatically updated to match its aspect
* ratio.
*/
setHeight(h: number): void;
}
/**
* Defines the parameters for creating a {@link IMarkupImage | markup image}.
*/
export interface IMarkupImageParams {
/**
* Screen coordinates of the top-left point (position) of the image.
*/
position?: {
x: number;
y: number;
};
/**
* Image source as a base64-encoded
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}.
*/
src?: string;
/**
* Width of the image. The original image is scaled to this width. Specify 0 to set width of the source
* image.
*
* @default 0
*/
width?: number;
/**
* Height of the image. The original image is scaled to this height. Specify 0 to set height of the
* source image.
*
* @default 0
*/
height?: number;
/**
* Maximum width of the image. Specify a max width if you want to set the width to the original image
* but not more than the max.
*/
maxWidth?: number;
/**
* Maximum height of the image. Specify a max height if you want to set the height to the original
* image but not more than the max.
*/
maxHeight?: number;
/**
* Internal markup object identifier.
*/
id?: string;
}