Line

A Line shape that extends the Shape class.

Line is a geometric line that doesn't have an area to be filled. For the line to be visible you specify the stroke size to be more that 0.

Line points are relative to the position of the Line shape. If you daw multiple lines that are related to each other, make sure to set same position for each of the lines.

Constructor

new Line(stroke, opacity, xopt, yopt, point1opt, point2opt)

Creates an instance of a Line shape.

Parameters:
NameTypeAttributesDefaultDescription
strokeStroke

A border of the shape.

opacitynumber1

Opacity of the shape (0 to 1).

xnumber<optional>
0

Horizontal position from the left edge.

ynumber<optional>
0

Vertical position from the top edge.

point1number<optional>

An object with X and Y coordinates {x: number, y: number}.

point2number<optional>

An object with X and Y coordinates {x: number, y: number}.

Classes

Line

Methods

point1(x, yopt) → {Line}

Sets or gets the first point of the line.

Parameters:
NameTypeAttributesDescription
xnumber | Object

X coordinate of the point, or an object with X and Y coordinates {x: number, y: number}.

ynumber<optional>

Y coordinate of the point (required only if x parameter is a number).

Returns:

If called without parameters, returns current point; otherwise returns this Line shape for chaining.

Type: 
Line

point2(x, yopt) → {Line}

Sets or gets the second point of the line.

Parameters:
NameTypeAttributesDescription
xnumber | Object

X coordinate of the point, or an object with X and Y coordinates {x: number, y: number}.

ynumber<optional>

Y coordinate of the point (required only if x parameter is a number).

Returns:

If called without parameters, returns current point; otherwise returns this Line shape for chaining.

Type: 
Line

toObject(includeopt) → {object}

Returns a JSON object that contains this shape properties. It may be converted back to this shape.

Parameters:
NameTypeAttributesDefaultDescription
includestring<optional>
"all"

Specified what to include. "all" is default. Valid values are: "all", "stroke", "background", "points", "basic".

Returns:

Returns an object containing this shape's properties.

Type: 
object