Line

Line

A class representing a line.

Constructor

new Line(fromopt, toopt, elementFromopt, elementToopt, chiralFromopt, chiralToopt)

Source:
Properties:
Name Type Description
from Vector2

The Vector2 defining the start of the line.

to Vector2

The Vector2 defining the end of the line.

elementFrom String

The element symbol associated with the start of the line.

elementTo String

The element symbol associated with the end of the line.

chiralFrom Boolean

A boolean indicating whether or not the source atom is a chiral center.

chiralTo Boolean

A boolean indicating whether or tno the target atom is a chiral center.

The constructor for the class Line.

Parameters:
Name Type Attributes Default Description
from Vector2 <optional>
new Vector2(0, 0)

A vector marking the beginning of the line.

to Vector2 <optional>
new Vector2(0, 0)

A vector marking the end of the line.

elementFrom string <optional>
null

A one-letter representation of the element associated with the vector marking the beginning of the line.

elementTo string <optional>
null

A one-letter representation of the element associated with the vector marking the end of the line.

chiralFrom Boolean <optional>
false

Whether or not the from atom is a chiral center.

chiralTo Boolean <optional>
false

Whether or not the to atom is a chiral center.

Methods

clone() → {Line}

Source:

Clones this line and returns the clone.

Returns:

A clone of this line.

Type
Line

getAngle() → {Number}

Source:

Returns the angle of the line in relation to the coordinate system (the x-axis).

Returns:

The angle in radians.

Type
Number

getLeftChiral() → {Boolean}

Source:

Returns whether or not the atom associated with the left vector (the vector with the smaller x value) is a chiral center.

Returns:

Whether or not the atom associated with the left vector is a chiral center.

Type
Boolean

getLeftElement() → {String}

Source:

Returns the element associated with the left vector (the vector with the smaller x value).

Returns:

The element associated with the left vector.

Type
String

getLeftVector() → {Vector2}

Source:

Returns the left vector (the vector with the smaller x value).

Returns:

The left vector.

Type
Vector2

getLength() → {Number}

Source:

Returns the length of this line.

Returns:

The length of this line.

Type
Number

getRightChiral() → {Boolean}

Source:

Returns whether or not the atom associated with the right vector (the vector with the larger x value) is a chiral center.

Returns:

Whether or not the atom associated with the right vector is a chiral center.

Type
Boolean

getRightElement() → {String}

Source:

Returns the element associated with the right vector (the vector with the larger x value).

Returns:

The element associated with the right vector.

Type
String

getRightVector() → {Vector2}

Source:

Returns the right vector (the vector with the larger x value).

Returns:

The right vector.

Type
Vector2

rotate(theta) → {Line}

Source:

Rotate the line by a given value (in radians). The center of rotation is the left vector.

Parameters:
Name Type Description
theta Number

The angle (in radians) to rotate the line.

Returns:

This line.

Type
Line

rotateToXAxis() → {Line}

Source:

Rotates this line to be aligned with the x-axis. The center of rotation is the left vector.

Returns:

This line.

Type
Line

setLeftVector(x, y) → {Line}

Source:

Set the value of the left vector.

Parameters:
Name Type Description
x Number

The x value.

y Number

The y value.

Returns:

This line.

Type
Line

setRightVector(x, y) → {Line}

Source:

Set the value of the right vector.

Parameters:
Name Type Description
x Number

The x value.

y Number

The y value.

Returns:

This line.

Type
Line

shorten(by) → {Line}

Source:

Shortens this line from both directions by a given value (in pixels).

Parameters:
Name Type Description
by Number

The length in pixels to shorten the vector by.

Returns:

This line.

Type
Line

shortenFrom(by) → {Line}

Source:

Shortens this line from the "from" direction by a given value (in pixels).

Parameters:
Name Type Description
by Number

The length in pixels to shorten the vector by.

Returns:

This line.

Type
Line

shortenLeft(by) → {Line}

Source:

Shorten the left side.

Parameters:
Name Type Description
by Number

The length in pixels to shorten the vector by.

Returns:

Returns itself.

Type
Line

shortenRight(by) → {Line}

Source:

Shorten the right side.

Parameters:
Name Type Description
by Number

The length in pixels to shorten the vector by.

Returns:

Returns itself.

Type
Line

shortenTo(by) → {Line}

Source:

Shortens this line from the "to" direction by a given value (in pixels).

Parameters:
Name Type Description
by Number

The length in pixels to shorten the vector by.

Returns:

This line.

Type
Line