Class: Layout

Layout

Layout manages image formats and tiling schemes in OpenLIME.

This class is responsible for:

  • Managing different image formats
  • Handling tiling schemes
  • Coordinating tile loading
  • Converting between coordinate systems
  • Managing tile priorities

Format Support:

  1. Single-resolution images:
  • Direct URL to image file
  • Supports all standard web formats (jpg, png, etc)
  1. Tiled formats:
  • DeepZoom (Microsoft): Uses .dzi config file
  • Google Maps: Direct directory structure
  • Zoomify: Uses ImageProperties.xml
  • IIIF: Standard server interface
  • TarZoom: OpenLIME's optimized format

new Layout(url, type [, options])

Creates a new Layout instance

Parameters:
Name Type Argument Description
url string

URL to image or configuration file

type LayoutType

Type of image layout

options LayoutOptions <optional>

Additional configuration

Source:
Fires:
  • Layout#event:ready - When layout is initialized and ready for use
  • Layout#event:updateSize - When layout dimensions change
Throws:

If layout type is unknown or module not loaded

Type
Error
Example
```javascript
// Single image
const imageLayout = new Layout('image.jpg', 'image');

// Deep Zoom
const dzLayout = new Layout('tiles.dzi', 'deepzoom');

// Google Maps format
const googleLayout = new Layout('tiles/', 'google', {
  width: 2000,
  height: 1500
});
```

Methods


available(viewport, transform, layerTransform, border, bias, tiles)

Gets tiles available for rendering

Parameters:
Name Type Description
viewport Object

Current viewport

transform Transform

Current transform

layerTransform Transform

Layer transform

border number

Border size

bias number

Mipmap bias

tiles Map

Existing tiles

Source:
Returns:

Map of available tiles

Type
Object.<number, Tile>

boundingBox()

Gets layout bounds

Source:
Returns:

Layout boundaries

Type
BoundingBox

getTileSize()

Gets tile dimensions

Source:
Returns:

[width, height] of tiles

Type
Array.<number>

<abstract> getTileURL(id, tile)

Gets URL for specific tile

Parameters:
Name Type Description
id number

Channel identifier

tile TileObj

Tile object

Source:
Returns:

Tile URL

Type
string

getViewportBox(viewport, transform, layerT)

Calculates viewport bounding box

Parameters:
Name Type Description
viewport Object

Viewport parameters

transform Transform

Current transform

layerT Transform

Layer transform

Source:
Returns:

Viewport bounds in image space

Type
BoundingBox

imageUrl(url, plane)

Constructs URL for specific image plane

Parameters:
Name Type Description
url string

Base URL

plane string

Plane identifier

Source:
Returns:

Complete URL

Type
string

needed(viewport, transform, layerTransform, border, bias, tiles [, maxtiles])

Determines required tiles for rendering

Parameters:
Name Type Argument Default Description
viewport Object

Current viewport

transform Transform

Current transform

layerTransform Transform

Layer transform

border number

Border size

bias number

Mipmap bias

tiles Map

Existing tiles

maxtiles number <optional>
8

Maximum tiles to return

Source:
Returns:

Array of needed tiles

Type
Array.<TileObj>

tileCoords(Obj})

Calculates tile coordinates

Parameters:
Name Type Description
Obj}

tile - Tile to calculate coordinates for

Source:
Returns:

Image and texture coordinates

Type
Object

Type Definitions


Type

Supported image layout types including both single-resolution and multi-resolution formats.

  • image: Standard web image formats (jpg, png, gif, etc.)
  • deepzoom: Microsoft Deep Zoom format with root tile > 1px
  • deepzoom1px: Microsoft Deep Zoom format with 1px root tile
  • google: Google Maps tiling scheme
  • zoomify: Zoomify tiling format
  • iiif: International Image Interoperability Framework
  • iip: Internet Imaging Protocol
  • tarzoom: OpenLIME custom format (single TAR of DeepZoom pyramid)
  • itarzoom: OpenLIME custom interleaved TAR format
Type:
  • 'image' | 'deepzoom' | 'deepzoom1px' | 'google' | 'zoomify' | 'iiif' | 'iip' | 'tarzoom' | 'itarzoom'
Source:

Events


ready

The event is fired when a layout is ready to be drawn(the single-resolution image is downloaded or the multi-resolution structure has been initialized).

Source:

ready

The event is fired when a layout is ready to be drawn(the single-resolution image is downloaded or the multi-resolution structure has been initialized).

Source:

updateSize

The event is fired when a layout size is modified (and the scene extension must be recomputed at canvas level).

Source: