Skip to main content

Class: SVGController

Defined in: SVGController.ts:37

Controller for managing the drawing of SVG shapes

Constructors

Constructor

new SVGController(container, options?): SVGController

Defined in: SVGController.ts:80

Creates the transform node inside the given container and registers the shape drawing event handlers

The viewport starts out as the unit square; setViewport is the only way to change it.

Parameters

container

SVGSVGElement

The <svg> element to draw on (typically created by createContainer)

options?

Optional shape drawing event handlers

onShapeComplete?

(shape) => void

Returns

SVGController

Properties

container

readonly container: SVGSVGElement

Defined in: SVGController.ts:38


shapeCompleteHandler?

readonly optional shapeCompleteHandler?: (shape) => void

Defined in: SVGController.ts:40

Parameters

shape

MultiPolygon

Returns

void


transformNode

readonly transformNode: SVGGElement

Defined in: SVGController.ts:39

Methods

destroy()

destroy(): void

Defined in: SVGController.ts:153

Returns

void


resizeContainer()

resizeContainer(newContainerSize): boolean

Defined in: SVGController.ts:132

Resizes the SVG container to match the given screen-space dimensions, accounting for devicePixelRatio

Parameters

newContainerSize

Dims

Desired container size in screen-space pixels

Returns

boolean

true if the container size actually changed, false otherwise


setInteractionMode()

setInteractionMode(newInteractionMode): void

Defined in: SVGController.ts:115

Updates the interaction mode

Parameters

newInteractionMode

InteractionMode

New interaction mode

Returns

void


setViewport()

setViewport(viewport): boolean

Defined in: SVGController.ts:101

Updates the world-space viewport rectangle

Parameters

viewport

Rect

New viewport bounds in world coordinates

Returns

boolean

true if the viewport actually changed, false otherwise


createContainer()

static createContainer(): SVGSVGElement

Defined in: SVGController.ts:60

Creates a positioned, full-size <svg> element for the SVG overlay

Returns

SVGSVGElement