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
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
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
openrv.view.fitToWidth();fitToWindow()
fitToWindow():
void
Defined in: api/ViewAPI.ts:76
Fit the image to the current window/viewport dimensions.
Returns
void
Example
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
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
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
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
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
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
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
openrv.view.setZoom(2.0); // zoom to 200%