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(containerSize, divToWorldSizeRatio, fitOffset)

Fit the layer to its parent container.

Parameters:
NameTypeDescription
containerSizeScalar2D

The container size as {x,y}.

divToWorldSizeRationumber

The div to world size ratio.

fitOffsetScalar2D

The fit offset as {x,y}.

flipScaleX()

Flip the scale along the layer X axis.

flipScaleY()

Flip the scale along the layer Y axis.

flipScaleZ()

Flip the scale along the layer Z axis.

getBaseSize() → {Scalar2D}

Get the layer base size (without scale).

Returns:

The size as {x,y}.

Type: 
Scalar2D

getDataId() → {string}

Get the associated data id.

Returns:

The id.

Type: 
string

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() → {Konva.Layer}

Get the Konva layer.

Returns:

The layer.

Type: 
Konva.Layer

getKonvaStage() → {Konva.Stage}

Get the Konva stage.

Returns:

The stage.

Type: 
Konva.Stage

getNumberOfDraws() → {number|undefined}

Get the total number of draws of this layer (at all positions).

Returns:

The total number of draws.

Type: 
number | undefined

getOpacity() → {number}

Get the layer opacity.

Returns:

The opacity ([0:1] range).

Type: 
number

initialise(size, spacing, dataId)

Initialise the layer: set the canvas and context.

Parameters:
NameTypeDescription
sizeScalar2D

The image size as {x,y}.

spacingScalar2D

The image spacing as {x,y}.

dataIdstring

The associated data id.

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.

removeFromDOM()

Remove the HTML element from the DOM.

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
newOffsetScalar3D

The offset as {x,y,z}.

setOpacity(alpha)

Set the layer opacity.

Parameters:
NameTypeDescription
alphanumber

The opacity ([0:1] range).

setPlaneHelper(helper)

Set the plane helper.

Parameters:
NameTypeDescription
helperPlaneHelper

The helper.

setScale(newScale, centeropt)

Set the layer scale.

Parameters:
NameTypeAttributesDescription
newScaleScalar3D

The scale as {x,y,z}.

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.