Constructor
new DrawLayer(containerDiv)
Name | Type | Description |
---|---|---|
containerDiv | HTMLDivElement | The layer div, its id will be used as this layer id. |
- Source
Classes
Methods
addEventListener(type, callback)
Add an event listener to this class.
Name | Type | Description |
---|---|---|
type | string | The event type. |
callback | function | The function associated with the provided event type, will be called with the fired event. |
- Source
addFlipOffsetX()
Add a flip offset along the layer X axis.
- Source
addFlipOffsetY()
Add a flip offset along the layer Y axis.
- Source
bindInteraction()
Enable and listen to container interaction events.
- Source
deleteDraw(id, exeCallback)
Delete a Draw from the stage.
Name | Type | Description |
---|---|---|
id | string | The id of the group to delete. |
exeCallback | object | The callback to call once the DeleteCommand has been executed. |
- Source
deleteDraws(exeCallback)
Delete all Draws from the stage.
Name | Type | Description |
---|---|---|
exeCallback | object | The callback to call once the DeleteCommand has been executed. |
- Source
display(flag)
Display the layer.
Name | Type | Description |
---|---|---|
flag | boolean | Whether to display the layer or not. |
- Source
draw()
Draw the content (imageData) of the layer. The imageData variable needs to be set.
- Source
fitToContainer(containerSize, divToWorldSizeRatio, fitOffset)
Fit the layer to its parent container.
Name | Type | Description |
---|---|---|
containerSize | Scalar2D | The container size as {x,y}. |
divToWorldSizeRatio | number | The div to world size ratio. |
fitOffset | Scalar2D | The fit offset as {x,y}. |
- Source
flipScaleX()
Flip the scale along the layer X axis.
- Source
flipScaleY()
Flip the scale along the layer Y axis.
- Source
flipScaleZ()
Flip the scale along the layer Z axis.
- Source
getBaseSize() → {Scalar2D}
Get the layer base size (without scale).
- Source
The size as {x,y}.
- Type:
- Scalar2D
getDataId() → {string}
Get the associated data id.
- Source
The id.
- Type:
- string
getDrawController() → {object}
Get the draw controller.
- Source
The controller.
- Type:
- object
getId() → {string}
Get the id of the layer.
- Source
The string id.
- Type:
- string
getKonvaLayer() → {Konva.Layer}
Get the Konva layer.
- Source
The layer.
- Type:
- Konva.
Layer
getKonvaStage() → {Konva.Stage}
Get the Konva stage.
- Source
The stage.
- Type:
- Konva.
Stage
getNumberOfDraws() → {number|undefined}
Get the total number of draws of this layer (at all positions).
- Source
The total number of draws.
- Type:
- number |
undefined
getOpacity() → {number}
Get the layer opacity.
- Source
The opacity ([0:1] range).
- Type:
- number
initialise(size, spacing, dataId)
Initialise the layer: set the canvas and context.
Name | Type | Description |
---|---|---|
size | Scalar2D | The image size as {x,y}. |
spacing | Scalar2D | The image spacing as {x,y}. |
dataId | string | The associated data id. |
- Source
isGroupVisible(id) → {boolean}
Check the visibility of a given group.
Name | Type | Description |
---|---|---|
id | string | The id of the group. |
- Source
True if the group is visible.
- Type:
- boolean
isVisible() → {boolean}
Check if the layer is visible.
- Source
True if the layer is visible.
- Type:
- boolean
removeEventListener(type, callback)
Remove an event listener from this class.
Name | Type | Description |
---|---|---|
type | string | The event type. |
callback | function | The function associated with the provided event type. |
- Source
removeFromDOM()
Remove the HTML element from the DOM.
- Source
setBaseOffset(scrollOffset, planeOffset) → {boolean}
Set the base layer offset. Updates the layer offset.
Name | Type | Description |
---|---|---|
scrollOffset | Vector3D | The scroll offset vector. |
planeOffset | Vector3D | The plane offset vector. |
- Source
True if the offset was updated.
- Type:
- boolean
setCurrentPosition(position, index) → {boolean}
Set the current position.
- Source
True if the position was updated.
- Type:
- boolean
setOffset(newOffset)
Set the layer offset.
Name | Type | Description |
---|---|---|
newOffset | Scalar3D | The offset as {x,y,z}. |
- Source
setOpacity(alpha)
Set the layer opacity.
Name | Type | Description |
---|---|---|
alpha | number | The opacity ([0:1] range). |
- Source
setPlaneHelper(helper)
Set the plane helper.
Name | Type | Description |
---|---|---|
helper | PlaneHelper | The helper. |
- Source
setScale(newScale, centeropt)
Set the layer scale.
Name | Type | Attributes | Description |
---|---|---|---|
newScale | Scalar3D | The scale as {x,y,z}. | |
center | Point3D | <optional> | The scale center. |
- Source
toggleGroupVisibility(id) → {boolean}
Toggle the visibility of a given group.
Name | Type | Description |
---|---|---|
id | string | The id of the group. |
- Source
False if the group cannot be found.
- Type:
- boolean
unbindInteraction()
Disable and stop listening to container interaction events.
- Source