Class: Compositor

Defined in: src/drawing/compositor.coffee

Overview

A utility class to transform an ensemble into a stack of images which can be drawn on a canvas.

Normally accessed via Totem#drawOn.

Instance Method Summary

Constructor Details

- (void) constructor(categories)

Create a new compositor.

Parameters:

  • categories (Array<string>) An array of category labels, in order. This is necessary for the compositor to know how to order the ensemble data it's given.

Instance Method Details

- (Object) prepare(ensemble)

Prepare a complete ensemble for drawing. Returns an array of <category>:<stack>, where <category> is a category label, and <stack> is an array of <cells>. Each cell is of form image:<String/HTMLImageElement>, colour:<String>. A cell's image: can be a url or an HTMLImageElement. colour: can be null or a hex colour value.

Parameters:

  • ensemble (Object) An ensemble to prepare

Returns:

  • (Object) — A composite (see above)

- (Array) prepareStack(asset)

Prepare an asset for drawing.

Parameters:

  • asset (Object) An asset collapsed to a given representation

Returns:

  • (Array) — An array of cells (see prepare)

- (Object) prepareCell(layer, colours)

Prepare an asset layer for drawing.

@param layer An asset layer

Parameters:

  • colours (Array) The two hex colours used by the asset

Returns:

  • (Object) — A cell (see prepare)