UNPKG

@inweb/markup

Version:
125 lines (108 loc) 3.83 kB
/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a // license agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// 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; }