Plexora

PluginLayerApi

ctx.layers: the viewer's rendering primitives, scoped to one plugin.

Generated from Plexora 0.0.55View source

A plugin says "draw these cells in these colours" or "draw this geometry" and core draws it; the plugin never builds a renderer of its own. Every id a plugin registers is prefixed with its name, so two plugins cannot collide, and everything a plugin drew is removed when it is torn down.

Properties

list() => LayerRecord[]required

Every layer of the sample, in compositing order.

find(query: {kind?: string, modality?: string}) => LayerRecord[]required

Layers matching a kind, a modality, or both. kind is how a layer is drawn; modality is what it means. The same vocabulary as plexora.api.layers on the server.

get(id: string) => Objectrequired

The layer stack's own record for one layer.

describe() => Objectrequired

A summary of the whole layer stack.

viewport() => Objectrequired

The visible region in image coordinates.

visibleCells() => number[]required

Ids of the cells currently on screen, from the centroid tiles already loaded (no request).

setColorLUT(layerId: string, lut: Object) => voidrequired

Colour cells: the plugin computes a lookup table, core draws it. Pass "cells" for this plugin's own cell layer.

setVisible(id: string, on: boolean) => voidrequired

Show or hide a layer.

setOpacity(id: string, value: number) => voidrequired

Set a layer's opacity, 0 to 1.

claim(id: string) => booleanrequired

Say "I draw this layer", which gives it an ordinary card (eye, opacity, drag) whose changes arrive through onLayerChange. Released automatically at teardown.

release(id: string) => booleanrequired

Undo claim.

setOrder(ids: string[]) => booleanrequired

Reorder layers; returns whether anything changed.

setTransform(id: string, transform: number[]) => voidrequired

Place a layer with an affine transform.

addOverlay(spec: Object) => Objectrequired

Draw temporary geometry. Returns a handle with remove().

removeOverlay(id: string) => voidrequired

Remove an overlay added with the same id.

addTiled(spec: Object) => ?{remove: Function, setStyle: Function, setVisible: Function}required

Add a tiled layer this plugin draws (for example a density raster). Core owns placement and z-order; the plugin owns the tiles. Returns null when the transform cannot be expressed.

removeTiled(id: string) => voidrequired

Remove a tiled layer.

repaint() => voidrequired

Redraw overlays now.

onViewportChange(fn: Function) => Functionrequired

Called at most once per animation frame while the view moves. Returns an unsubscribe function; also removed at teardown.

onLayerChange(fn: Function) => Functionrequired

Called when any layer is shown, hidden, faded, reordered or added. Returns an unsubscribe function.