# JSDoc: Class: Line

# Class: Line

## Line()

#### new Line()

Line object draw a line from one point to another.

Source:
  - objects/Line.js, line 12

### Extends

- Object2D

### Members

#### beingDragged

Flag to indicate if the object is currently being dragged.

Inherited From:
  - Object2D#beingDragged
Source:
  - Object2D.js, line 142

#### children

List of children objects attached to the object.

Inherited From:
  - Object2D#children
Source:
  - Object2D.js, line 26

#### dashPattern

Dash line pattern to be used, if empty draws a solid line. Dash parttern is defined as the size of dashes as pairs of space with no line and with line. E.g if the daspattern is [1, 2] we get 1 point with line, 2 without line repeat infinitelly.

Source:
  - objects/Line.js, line 37

#### draggable

Indicates if its possible to drag the object around. If true the onPointerDrag callback is used to update the state of the object.

Inherited From:
  - Object2D#draggable
Source:
  - Object2D.js, line 108

#### from

Initial point of the line. Can be equal to the position object of another object. (Making it automatically follow that object.)

Source:
  - objects/Line.js, line 21

#### globalMatrix

Global transformation matrix multiplied by the parent matrix. Used to transform the object before projecting into screen coordinates.

Inherited From:
  - Object2D#globalMatrix
Source:
  - Object2D.js, line 82

#### ignoreViewport

Flag to indicate wheter this objet ignores the viewport transformation.

Inherited From:
  - Object2D#ignoreViewport
Source:
  - Object2D.js, line 120

#### inverseGlobalMatrix

Inverse of the global matrix. Used to convert pointer input points into object coordinates.

Inherited From:
  - Object2D#inverseGlobalMatrix
Source:
  - Object2D.js, line 89

#### layer

Layer of this object, objects are sorted by layer value. Lower layer value is draw first.

Inherited From:
  - Object2D#layer
Source:
  - Object2D.js, line 70

#### level

Depth level in the object tree, objects with higher depth are drawn on top. The layer value is considered first.

Inherited From:
  - Object2D#level
Source:
  - Object2D.js, line 38

#### lineWidth

Line width of the line.

Source:
  - objects/Line.js, line 47

#### masks

Masks being applied to this object. Multiple masks can be used simultaneously.

Inherited From:
  - Object2D#masks
Source:
  - Object2D.js, line 96

#### matrix

Local transformation matrix applied to the object.

Inherited From:
  - Object2D#matrix
Source:
  - Object2D.js, line 75

#### matrixNeedsUpdate

If true the matrix is updated before rendering the object.

Inherited From:
  - Object2D#matrixNeedsUpdate
Source:
  - Object2D.js, line 101

#### onAdd

Method called when the object its added to a parent.

Inherited From:
  - Object2D#onAdd
Source:
  - Object2D.js, line 316

#### onButtonDown

Callback method called when the pointer button is pressed down (single time). Receives (pointer, viewport) as arguments.

Inherited From:
  - Object2D#onButtonDown
Source:
  - Object2D.js, line 390

#### onButtonPressed

Callback method called while the pointer button is pressed. Receives (pointer, viewport) as arguments.

Inherited From:
  - Object2D#onButtonPressed
Source:
  - Object2D.js, line 370

#### onButtonUp

Callback method called when the pointer button is released (single time). Receives (pointer, viewport) as arguments.

Inherited From:
  - Object2D#onButtonUp
Source:
  - Object2D.js, line 400

#### onDoubleClick

Callback method called while the pointer button is double clicked. Receives (pointer, viewport) as arguments.

Inherited From:
  - Object2D#onDoubleClick
Source:
  - Object2D.js, line 380

#### onPointerEnter

Callback method called when the pointer enters the object. Receives (pointer, viewport) as arguments.

Inherited From:
  - Object2D#onPointerEnter
Source:
  - Object2D.js, line 340

#### onPointerLeave

Callback method called when the was inside of the object and leaves the object. Receives (pointer, viewport) as arguments.

Inherited From:
  - Object2D#onPointerLeave
Source:
  - Object2D.js, line 350

#### onPointerOver

Callback method while the pointer is over (inside) of the object. Receives (pointer, viewport) as arguments.

Inherited From:
  - Object2D#onPointerOver
Source:
  - Object2D.js, line 360

#### onRemove

Method called when the object gets removed from its parent

Inherited From:
  - Object2D#onRemove
Source:
  - Object2D.js, line 323

#### onUpdate

Callback method called every time before the object is draw into the canvas. Can be used to run preparation code, move the object, etc.

Inherited From:
  - Object2D#onUpdate
Source:
  - Object2D.js, line 330

#### origin

Origin of the object used as point of rotation.

Inherited From:
  - Object2D#origin
Source:
  - Object2D.js, line 48

#### parent

Parent object, the object position is affected by its parent position.

Inherited From:
  - Object2D#parent
Source:
  - Object2D.js, line 31

#### pointerEvents

Indicates if this object uses pointer events. Can be set false to skip the pointer interaction events.

Inherited From:
  - Object2D#pointerEvents
Source:
  - Object2D.js, line 115

#### pointerInside

Flag indicating if the pointer is inside of the element. Used to control object event.

Inherited From:
  - Object2D#pointerInside
Source:
  - Object2D.js, line 137

#### position

Position of the object.

Inherited From:
  - Object2D#position
Source:
  - Object2D.js, line 43

#### restoreContextState

Flag to indicate if the context of canvas should be restored after render.

Inherited From:
  - Object2D#restoreContextState
Source:
  - Object2D.js, line 130

#### rotation

Rotation of the object relative to its center.

Inherited From:
  - Object2D#rotation
Source:
  - Object2D.js, line 58

#### saveContextState

Flag to indicate if the context of canvas should be saved before render.

Inherited From:
  - Object2D#saveContextState
Source:
  - Object2D.js, line 125

#### scale

Scale of the object.

Inherited From:
  - Object2D#scale
Source:
  - Object2D.js, line 53

#### strokeStyle

Style of the object line.

Source:
  - objects/Line.js, line 42

#### to

Final point of the line. Can be equal to the position object of another object. (Making it automatically follow that object.)

Source:
  - objects/Line.js, line 28

#### uuid

UUID of the object.

Inherited From:
  - Object2D#uuid
Source:
  - Object2D.js, line 21

#### visible

Indicates if the object is visible.

Inherited From:
  - Object2D#visible
Source:
  - Object2D.js, line 63

### Methods

#### add(object)

Attach a children to this object. The object is set as children of this object and the transformations applied to this object are traversed to its children.

##### Parameters:

Name | Type | Description
--- | --- | ---
`object` | Object2D | Object to attach to this object.

Inherited From:
  - Object2D#add
Source:
  - Object2D.js, line 190

#### draw(context, viewport, canvas)

Draw the object into the canvas. Has to be implemented by underlying classes.

##### Parameters:

Name | Type | Description
--- | --- | ---
`context` | CanvasContext | Canvas 2d drawing context.
`viewport` | Viewport | Viewport applied to the canvas.
`canvas` | DOM | DOM canvas element where the content is being drawn.

Overrides:
  - Object2D#draw
Source:
  - Object2D.js, line 291

#### getChildByUUID(uuid) → {Object2D}

Get a object from its children list by its UUID.

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of the object to get.

Inherited From:
  - Object2D#getChildByUUID
Source:
  - Object2D.js, line 168

##### Returns:

The object that has the UUID specified, null if the object was not found.

Type
  Object2D

#### isInside() → {boolean}

Check if a point is inside of the object. Used to update the point events attached to the object.

Inherited From:
  - Object2D#isInside
Source:
  - Object2D.js, line 240

##### Returns:

True if the point is inside of the object.

Type
  boolean

#### onPointerDrag(pointer, viewport, delta)

Callback method while the object is being dragged across the screen. By default is adds the delta value to the object position (making it follow the mouse movement). Delta is the movement of the pointer already translated into local object coordinates. Receives (pointer, viewport, delta) as arguments.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pointer` | Pointer | Pointer object that receives the user input.
`viewport` | Viewport | Viewport where the object is drawn.
`delta` | Vector2 | Pointer movement in world space.

Inherited From:
  - Object2D#onPointerDrag
Source:
  - Object2D.js, line 306

#### remove(object)

Remove object from the children list.

##### Parameters:

Name | Type | Description
--- | --- | ---
`object` | Object2D | Object to be removed.

Inherited From:
  - Object2D#remove
Source:
  - Object2D.js, line 211

#### transform(context, viewport)

Apply the transform to the rendering context. It is assumed that the viewport transform is pre-applied to the context. Can also be used for pre rendering logic.

##### Parameters:

Name | Type | Description
--- | --- | ---
`context` | CanvasContext | Canvas 2d drawing context.
`viewport` | Viewport | Viewport applied to the canvas.

Inherited From:
  - Object2D#transform
Source:
  - Object2D.js, line 277

#### traverse(callback)

Traverse the object tree and run a function for all objects.

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | function | Callback function that receives the object as parameter.

Inherited From:
  - Object2D#traverse
Source:
  - Object2D.js, line 150

#### updateMatrix(context)

Update the transformation matrix of the object.

##### Parameters:

Name | Type | Description
--- | --- | ---
`context` | CanvasContext |

Inherited From:
  - Object2D#updateMatrix
Source:
  - Object2D.js, line 250