@ue-too/board / CanvasCacheInWebWorker
Class: CanvasCacheInWebWorker
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:112
Abstraction interface for canvas element access and manipulation.
Remarks
This interface provides a decoupled way to access canvas properties without direct DOM access. Multiple implementations exist to support different use cases:
- CanvasProxy: Full implementation for HTML canvas elements with dimension tracking
- SvgProxy: Implementation for SVG elements
- DummyCanvas: No-op implementation for web worker contexts
- WorkerRelayCanvas: Relays canvas dimension updates to web workers
- CanvasCacheInWebWorker: Caches canvas dimensions within a web worker
The abstraction enables:
- Coordinate system transformations (window → canvas → viewport)
- Canvas dimension tracking without repeated DOM queries
- Cursor style management
- Support for both canvas and SVG rendering contexts
Implements
Constructors
Constructor
new CanvasCacheInWebWorker(
postMessageFunction):CanvasCacheInWebWorker
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:118
Parameters
postMessageFunction
{(message, targetOrigin, transfer?): void; (message, options?): void; }
Returns
CanvasCacheInWebWorker
Accessors
detached
Get Signature
get detached():
boolean
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:163
Whether the canvas is currently detached from the DOM
Returns
boolean
Whether the canvas is currently detached from the DOM
Implementation of
dimensions
Get Signature
get dimensions():
object
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:125
Combined dimensions and position information
Returns
object
height
height:
number
position
position:
Point
width
width:
number
Combined dimensions and position information
Implementation of
height
Get Signature
get height():
number
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:151
The canvas height in CSS pixels
Returns
number
Set Signature
set height(
height):void
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:139
The canvas height in CSS pixels
Parameters
height
number
Returns
void
The canvas height in CSS pixels
Implementation of
position
Get Signature
get position():
Point
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:155
The top-left position of the canvas in window coordinates
Returns
Point
Set Signature
set position(
position):void
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:143
The top-left position of the canvas in window coordinates
Parameters
position
Point
Returns
void
The top-left position of the canvas in window coordinates
Implementation of
width
Get Signature
get width():
number
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:147
The canvas width in CSS pixels
Returns
number
Set Signature
set width(
width):void
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:135
The canvas width in CSS pixels
Parameters
width
number
Returns
void
The canvas width in CSS pixels
Implementation of
Methods
setCursor()
setCursor(
style):void
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:159
Sets the CSS cursor style for visual feedback
Parameters
style
"grab" | "default" | "grabbing"
Returns
void
Implementation of
tearDown()
tearDown():
void
Defined in: packages/board/src/input-interpretation/input-state-machine/kmt-input-context.ts:133
Cleanup method to dispose of resources and event listeners
Returns
void