# Class: Line

### Classes

- BezierPath
- CubicBezierCurve
- drawutils
- Grid
- Line
- PBImage
- PlotBoilerplate
- Polygon
- Vector
- VEllipse
- Vertex
- VertexAttr
- VertexListeners

### Global

## Line(a, b)

#### new Line(a, b)

Creates an instance of Line.

##### Parameters:

Name | Type | Description |
---|---|---|

`a` |
Vertex | The line's first point. |

`b` |
Vertex | The line's second point. |

### Members

#### a :Vertex

##### Type:

#### b :Vertex

##### Type:

### Methods

#### add(amount) → {Line}

Add the given vertex from this line's end points.

##### Parameters:

Name | Type | Description |
---|---|---|

`amount` |
Vertex | The amount (x,y) to add. |

##### Returns:

this

- Type
- Line

#### angle(line) → {number}

Get the angle between this and the passed line (in radians).

##### Parameters:

Name | Type | Description |
---|---|---|

`line` |
Line | The line to calculate the angle to. |

##### Returns:

this

- Type
- number

#### clone() → {Line}

Create a deep clone of this line.

##### Returns:

A copy if this line.

- Type
- Line

#### getClosestT(p) → {number}

Get the closest position T from this line to the specified point.
The counterpart for this function is Line.vertAt(Number).

##### Parameters:

Name | Type | Description |
---|---|---|

`p` |
Vertex | The point (vertex) to measre the distance to. |

##### Returns:

The line position t of minimal distance to p.

- Type
- number

#### intersection(line) → {Vertex}

Get the intersection if this line and the specified line.

##### Parameters:

Name | Type | Description |
---|---|---|

`line` |
Line | The second line. |

##### Returns:

The intersection (may lie outside the end-points).

- Type
- Vertex

#### length()

Get the length of this line.

#### moveTo(newA) → {Line}

Move this line to a new location.

##### Parameters:

Name | Type | Description |
---|---|---|

`newA` |
Vertex | The new desired location of 'a'. Vertex 'b' will be moved, too. |

##### Returns:

this

- Type
- Line

#### normalize() → {Line}

Normalize this line (set to length 1).

##### Returns:

this

- Type
- Line

#### pointDistance(p) → {number}

The the minimal distance between this line and the specified point.

##### Parameters:

Name | Type | Description |
---|---|---|

`p` |
Vertex | The point (vertex) to measre the distance to. |

##### Returns:

The absolute minimal distance.

- Type
- number

#### scale(factor) → {Line}

Scale this line by the given factor.

##### Parameters:

Name | Type | Description |
---|---|---|

`factor` |
number | The factor for scaling (1.0 means no scale). |

##### Returns:

this

- Type
- Line

#### sub(amount) → {Line}

Substract the given vertex from this line's end points.

##### Parameters:

Name | Type | Description |
---|---|---|

`amount` |
Vertex | The amount (x,y) to substract. |

##### Returns:

this

- Type
- Line

#### toSVGString(p) → {string}

Create an SVG representation of this line.

##### Parameters:

Name | Type | Description |
---|---|---|

`p` |
options | A set of options, like the 'classname' to use for the line object. |

##### Returns:

The SVG string representing this line.

- Type
- string

#### totring() → {string}

Create a string representation of this line.

##### Returns:

The string representing this line.

- Type
- string

#### vertAt(t) → {Vertex}

Get line point at position t in [0 ... 1]:

The counterpart of this function is Line.getClosestT(Vertex).

[P(0)]=[A]--------------------[P(t)]------[B]=[P(1)]

The counterpart of this function is Line.getClosestT(Vertex).

##### Parameters:

Name | Type | Description |
---|---|---|

`t` |
number | The position scalar. |

##### Returns:

The vertex a position t.

- Type
- Vertex