# GridThumbnail Class

    public class GridThumbnail

GridThumbnail

Used to define a request to download images and slice them into multiple thumbnails in a grid pattern. Each image will be sliced into smaller segments based on the `gridWidth` and `gridHeight`. E.g. if these are both set to `2`, then the image will be divided into a 2 x 2 grid producing 4 equal sized thumbnails per image. The grid cells are ordered from left to right, then top to bottom.

Single or multiple images may be downloaded using this object. If `maxIndex` is greater than 1 and the `pathTemplate` contains the token index then multiple image urls can be specified. The final image urls which will be downloaded are specified by the baseUrl + the result of the pathTemplate substitution. The index token in pathTemplate will be substituted with the index 1 up to and including maxIndex. E.g. if `pathTemplate` where `image_$index$.jpg` and maxIndex were 3, then `image_1.jpg`, `image_2.jpg`, `image_3.jpg` would be generated from the substitution.

Each thumbnail will be displayed for `durationMs` with no gabs in between. Therefore thumbnails will cover a total timerange of `durationMs` multiplied by the total number of thumbnails generated.

### Lifecycle

- `init(baseUrl:pathTemplate:gridHeight:gridWidth:durationMs:maxIndex:)`

  Creates a grid-thumbnail descriptor from explicit URL templating inputs.

  #### Declaration

  Swift

      public init(
          baseUrl: URL,
          pathTemplate: String,
          gridHeight: Int,
          gridWidth: Int,
          durationMs: Int64,
          maxIndex: Int
      )

  #### Parameters

  `baseUrl` | Base URL used to resolve image requests.
  `pathTemplate` | Path template, optionally containing index placeholders.
  `gridHeight` | Number of rows in each grid image.
  `gridWidth` | Number of columns in each grid image.
  `durationMs` | Per-cell display duration in milliseconds.
  `maxIndex` | Highest substituted index for multi-image templates.

- `init(baseUrl:gridHeight:gridWidth:durationMs:)`

  Creates a grid-thumbnail descriptor from a single URL that may include `$index$_N`.

  #### Declaration

  Swift

      convenience public init(
          baseUrl: URL,
          gridHeight: Int,
          gridWidth: Int,
          durationMs: Int64
      )

  #### Parameters

  `baseUrl` | Full thumbnail URL or template URL.
  `gridHeight` | Number of rows in each grid image.
  `gridWidth` | Number of columns in each grid image.
  `durationMs` | Per-cell display duration in milliseconds.

### Public

- `baseUrl`

  Grid image Url (excluding path).

  #### Declaration

  Swift

      public var baseUrl: URL

- `pathTemplate`

  Url path template (may include index variables).

  #### Declaration

  Swift

      public var pathTemplate: String

- `gridHeight`

  Number of columns.

  #### Declaration

  Swift

      public var gridHeight: Int

- `gridWidth`

  Number of rows.

  #### Declaration

  Swift

      public var gridWidth: Int

- `durationMs`

  Grid elements time difference / Thumbnail duration in milliseconds.

  #### Declaration

  Swift

      public var durationMs: Int64

- `maxIndex`

  Number of grid images to download.

  #### Declaration

  Swift

      public var maxIndex: Int