Document Solutions Image Viewer
    Preparing search index...

    Interface PaintObject<T>

    Core interface representing a paint object that can be rendered on canvas.

    interface PaintObject<T> {
        type: T;
        name: string;
        bounds: Bounds;
        startPosition: PointLocation;
        endPosition: PointLocation;
        canvasPadding: number;
        draw(
            destCtx: CanvasRenderingContext2D,
            mainCtx: CanvasRenderingContext2D,
            backCtx: CanvasRenderingContext2D,
            params?: PaintObjectParameters,
        ): Promise<void>;
        getContentSize(ctx: CanvasRenderingContext2D): Size;
        getProperty<K extends PaintObjectPropertyName>(propertyName: K): any;
        setProperty<K extends PaintObjectPropertyName>(
            propertyName: K,
            value: any,
        ): boolean;
        resetToFactoryDefaults(): void;
    }

    Type Parameters

    • T

      The specific type of paint object (e.g., 'rectangle', 'line')

    Methods

    • Renders the object to the specified canvas context

      Parameters

      • destCtx: CanvasRenderingContext2D

        Primary drawing context

      • mainCtx: CanvasRenderingContext2D

        Main canvas context (for composite operations)

      • backCtx: CanvasRenderingContext2D

        Background context (for layered rendering)

      • Optionalparams: PaintObjectParameters

        Optional rendering parameters

      Returns Promise<void>

    • Calculates the content dimensions of the object

      Parameters

      • ctx: CanvasRenderingContext2D

        Canvas context used for measurements (e.g., text metrics)

      Returns Size

      Size object containing width and height

    • Retrieves a property value by name

      Type Parameters

      Parameters

      • propertyName: K

        Name of the property to retrieve

      Returns any

      The property value or undefined if not found

    • Updates a property value by name

      Type Parameters

      Parameters

      • propertyName: K

        Name of the property to set

      • value: any

        New value for the property

      Returns boolean

      True if the property was changed, false otherwise

    • Resets all user-modified properties of the object back to their registered factory default values.

      Returns void

    Properties

    type: T

    The type identifier of the paint object (e.g., 'line', 'rectangle')

    name: string

    The display name of the paint object

    bounds: Bounds

    Gets the bounding rectangle of the object in canvas coordinates

    startPosition: PointLocation

    Gets the end position (particularly relevant for line objects)

    endPosition: PointLocation

    Gets the end position (particularly relevant for line objects)

    canvasPadding: number

    Returns the additional padding (in pixels) required around the object to accommodate all visual elements like styled line caps. This is useful for properly sizing the canvas when rendering this object.