Skip to content

openrv-web / ViewAPI

Class: ViewAPI

Defined in: api/ViewAPI.ts:29

Constructors

Constructor

new ViewAPI(viewer): ViewAPI

Defined in: api/ViewAPI.ts:32

Parameters

viewer

ViewerProvider

Returns

ViewAPI

Methods

fitToHeight()

fitToHeight(): void

Defined in: api/ViewAPI.ts:102

Fit the image height to the container height. The image fills the viewport height; user can pan horizontally.

Returns

void

Example

ts
openrv.view.fitToHeight();

fitToWidth()

fitToWidth(): void

Defined in: api/ViewAPI.ts:89

Fit the image width to the container width. The image fills the viewport width; user can pan vertically.

Returns

void

Example

ts
openrv.view.fitToWidth();

fitToWindow()

fitToWindow(): void

Defined in: api/ViewAPI.ts:76

Fit the image to the current window/viewport dimensions.

Returns

void

Example

ts
openrv.view.fitToWindow();

getChannel()

getChannel(): string

Defined in: api/ViewAPI.ts:189

Get the current channel isolation mode.

Returns

string

The active channel mode string (e.g., 'rgb', 'red', 'alpha').

Example

ts
const channel = openrv.view.getChannel(); // e.g. 'rgb'

getFitMode()

getFitMode(): string | null

Defined in: api/ViewAPI.ts:116

Get the current fit mode.

Returns

string | null

The active fit mode ('all', 'width', 'height') or null if no fit mode is active.

Example

ts
const mode = openrv.view.getFitMode(); // e.g. 'width'

getPan()

getPan(): object

Defined in: api/ViewAPI.ts:149

Get the current pan offset.

Returns

object

An object with x and y pixel offsets.

x

x: number

y

y: number

Example

ts
const { x, y } = openrv.view.getPan();

getZoom()

getZoom(): number

Defined in: api/ViewAPI.ts:64

Get the current zoom level.

Returns

number

The current zoom level (e.g., 1.0 = 100%).

Example

ts
const zoom = openrv.view.getZoom();

setChannel()

setChannel(mode): void

Defined in: api/ViewAPI.ts:166

Set the channel isolation mode for viewing.

Parameters

mode

string

Channel mode: 'rgb', 'red', 'green', 'blue', 'alpha', 'luminance'. Also accepts shorthand aliases: 'r', 'g', 'b', 'a', 'luma', 'l'. The value is case-insensitive.

Returns

void

Throws

If mode is not a string or is not a recognized channel name.

Example

ts
openrv.view.setChannel('alpha');

setPan()

setPan(x, y): void

Defined in: api/ViewAPI.ts:132

Set the pan offset in pixels.

Parameters

x

number

Horizontal pan offset in pixels (positive = right).

y

number

Vertical pan offset in pixels (positive = down).

Returns

void

Throws

If x or y is not a valid number or is NaN.

Example

ts
openrv.view.setPan(100, -50);

setZoom()

setZoom(level): void

Defined in: api/ViewAPI.ts:47

Set the zoom level of the viewport.

Parameters

level

number

Zoom level as a positive number (e.g., 1.0 = 100%, 2.0 = 200%).

Returns

void

Throws

If level is not a positive number or is NaN.

Example

ts
openrv.view.setZoom(2.0); // zoom to 200%

Released under the MIT License.