OMD Documentation

FocusFrameManager

The FocusFrameManager is a feature that allows you to define rectangular regions on the canvas called "focus frames." These frames can be used to highlight specific areas of interest, capture their contents as separate SVG or bitmap images, and manage them independently.

This is particularly useful for applications where you need to isolate and process or export specific parts of a larger drawing, such as individual mathematical problems on a worksheet or specific diagrams in a complex scene.

Class Definition

export class FocusFrameManager {
    // ...
}

Constructor

new FocusFrameManager(canvas)

Creates a new FocusFrameManager instance.

Public Methods

createFrame([options])

Creates a new, independent focus frame on the canvas.

removeFrame(frameId)

Removes a specific focus frame from the canvas.

getFrame(frameId)

Retrieves a focus frame instance by its ID.

setActiveFrame(frameId)

Sets a specific frame as the "active" one, which can be useful for highlighting or targeting operations.

getActiveFrame()

Gets the currently active focus frame.

captureActiveFrame()

Captures the SVG content of the currently active focus frame.

captureAllFrames()

Captures the content of every focus frame on the canvas.

clearAllFrames()

Removes all focus frames from the canvas.

getFrameIds()

Gets the IDs of all current focus frames.

destroy()

Destroys the manager and removes all associated frames and event listeners.


The FocusFrame Class (Internal)

The FocusFrame class represents a single rectangular frame. It is not exported directly but is returned by FocusFrameManager methods.

setActive(active)

Sets the frame's visual state to active or inactive.

capture()

Captures the canvas content within the frame's bounds.

async toBitmap([format], [quality])

Converts the frame's captured content into a bitmap image.

async downloadAsBitmap([filename], [format])

Triggers a browser download of the frame's content as a bitmap image.

updateBounds(bounds)

Resizes and/or repositions the frame.

getBounds()

Gets the current position and size of the frame.

destroy()

Removes the frame's visual element from the canvas.

↑ Top