DrawLayer

Draw layer.

Constructor

new DrawLayer(containerDiv)

Parameters:
NameTypeDescription
containerDivHTMLDivElement

The layer div, its id will be used as this layer id.

Classes

DrawLayer

Methods

addEventListener(type, callback)

Add an event listener to this class.

Parameters:
NameTypeDescription
typestring

The event type.

callbackfunction

The function associated with the provided event type, will be called with the fired event.

addFlipOffsetX()

Add a flip offset along the layer X axis.

addFlipOffsetY()

Add a flip offset along the layer Y axis.

bindInteraction()

Enable and listen to container interaction events.

deleteDraw(id, exeCallback)

Delete a Draw from the stage.

Parameters:
NameTypeDescription
idstring

The id of the group to delete.

exeCallbackobject

The callback to call once the DeleteCommand has been executed.

deleteDraws(exeCallback)

Delete all Draws from the stage.

Parameters:
NameTypeDescription
exeCallbackobject

The callback to call once the DeleteCommand has been executed.

display(flag)

Display the layer.

Parameters:
NameTypeDescription
flagboolean

Whether to display the layer or not.

draw()

Draw the content (imageData) of the layer. The imageData variable needs to be set

fitToContainer(fitScale1D, fitSize, fitOffset)

Fit the layer to its parent container.

Parameters:
NameTypeDescription
fitScale1Dnumber

The 1D fit scale.

fitSizeobject

The fit size as {x,y}.

fitOffsetobject

The fit offset as {x,y}.

getBaseSize() → {object}

Get the layer base size (without scale).

Returns:

The size as {x,y}.

Type: 
object

getDataIndex() → {number}

Get the associated data index.

Returns:

The index.

Type: 
number

getDrawController() → {object}

Get the draw controller.

Returns:

The controller.

Type: 
object

getId() → {string}

Get the id of the layer.

Returns:

The string id.

Type: 
string

getKonvaLayer() → {object}

Get the Konva layer.

Returns:

The layer.

Type: 
object

getKonvaStage() → {object}

Get the Konva stage.

Returns:

The stage.

Type: 
object

getOpacity() → {number}

Get the layer opacity.

Returns:

The opacity ([0:1] range).

Type: 
number

initialise(size, spacing, index)

Initialise the layer: set the canvas and context

Parameters:
NameTypeDescription
sizeobject

The image size as {x,y}.

spacingobject

The image spacing as {x,y}.

indexnumber

The associated data index.

isGroupVisible(id) → {boolean}

Check the visibility of a given group.

Parameters:
NameTypeDescription
idstring

The id of the group.

Returns:

True if the group is visible.

Type: 
boolean

isVisible() → {boolean}

Check if the layer is visible.

Returns:

True if the layer is visible.

Type: 
boolean

removeEventListener(type, callback)

Remove an event listener from this class.

Parameters:
NameTypeDescription
typestring

The event type.

callbackfunction

The function associated with the provided event type.

setBaseOffset(scrollOffset, planeOffset) → {boolean}

Set the base layer offset. Updates the layer offset.

Parameters:
NameTypeDescription
scrollOffsetVector3D

The scroll offset vector.

planeOffsetVector3D

The plane offset vector.

Returns:

True if the offset was updated.

Type: 
boolean

setCurrentPosition(position, index) → {boolean}

Set the current position.

Parameters:
NameTypeDescription
positionPoint

The new position.

indexIndex

The new index.

Returns:

True if the position was updated.

Type: 
boolean

setOffset(newOffset)

Set the layer offset.

Parameters:
NameTypeDescription
newOffsetobject

The offset as {x,y}.

setOpacity(alpha)

Set the layer opacity.

Parameters:
NameTypeDescription
alphanumber

The opacity ([0:1] range).

setPlaneHelper(helper)

Set the plane helper.

Parameters:
NameTypeDescription
helperobject

The helper.

setScale(newScale, centeropt)

Set the layer scale.

Parameters:
NameTypeAttributesDescription
newScaleobject

The scale as {x,y}.

centerPoint3D<optional>

The scale center.

toggleGroupVisibility(id) → {boolean}

Toggle the visibility of a given group.

Parameters:
NameTypeDescription
idstring

The id of the group.

Returns:

False if the group cannot be found.

Type: 
boolean

unbindInteraction()

Disable and stop listening to container interaction events.