Line

Line

new Line(x1, y1, x2, y2)

Source:
Parameters:
Name Type Description
x1 number x coordinate of starting point of line.
y1 number y coordinate of starting point of line.
x2 number x coordinate of end point of line.
y2 number y coordinate of end point of line.

Extends

Methods

containsPoint(x, y)

Checks if a given point is contained in the line.
Overrides:
Source:
Parameters:
Name Type Description
x number x coordinate of the point being tested.
y number y coordinate of the point being tested.

draw(__graphics__)

Draws the line in the canvas.
Overrides:
Source:
Parameters:
Name Type Description
__graphics__ CodeHSGraphics Instance of the __graphics__ module.

getBorderColor() → {Color}

Gets the border color of a Thing.
Inherited From:
Source:
Returns:
Type:
Color
The color of the Thing's border.

getBorderWidth() → {number}

Gets the width of the Thing's border.
Inherited From:
Source:
Returns:
Type:
number
The width of the Thing's border.

getColor() → {Color}

Gets the color of a line.
Overrides:
Source:
Returns:
Type:
Color
Color of the line.

getEndX() → {number}

Gets the x coordinate of the Line's end point.
Source:
Returns:
Type:
number
The x coordinate of the Line's end point.

getEndY() → {number}

Gets the y coordinate of the Line's end point.
Source:
Returns:
Type:
number
The y coordinate of the Line's end point.

getHeight() → {number}

Returns the height of the line.
Source:
Returns:
Type:
number
The width of the line.

getStartX() → {number}

Gets the x coordinate of the Line's start point.
Source:
Returns:
Type:
number
The x coordinate of the Line's start point.

getStartY() → {number}

Gets the y coordinate of the Line's start point.
Source:
Returns:
Type:
number
The y coordinate of the Line's start point.

getType() → {type}

Returns the type of a Thing.
Inherited From:
Source:
Returns:
Type:
type
The type of the Thing.

getWidth() → {number}

Returns the width of the line.
Source:
Returns:
Type:
number
The width of the line.

getX() → {number}

Gets the x coordinate of the Line's start point.
Overrides:
Source:
Returns:
Type:
number
The x coordinate of the Line's start point.

getY() → {number}

Gets the y coordinate of the Line's start point.
Overrides:
Source:
Returns:
Type:
number
The y coordinate of the Line's start point.

hasBorder() → {boolean}

Returns if a Thing has a border.
Inherited From:
Source:
Returns:
Type:
boolean
True if the Thing has a border.

isFilled() → {boolean}

Returns if a Thing is filled.
Inherited From:
Source:
Returns:
Type:
boolean
True if the Thing is filled.

move(dx, dy)

Moves the entire line.
Overrides:
Source:
Parameters:
Name Type Description
dx number The change in x coordinate of both starting and ending points.
dy number The change in y coordinate of both starting and ending points.

rotate(degrees, angleUnit)

Rotates a Thing an additional amount of degrees.
Inherited From:
Source:
Parameters:
Name Type Description
degrees number The degrees to rotate degrees.
angleUnit number Whether it is degrees or radians. Defaults to degrees.

setBorder(hasBorder)

Sets a Thing object to filled. Throws an error if an argument is not passed.
Inherited From:
Source:
Parameters:
Name Type Description
hasBorder bool A boolean of whether or not Thing has a border.

setBorderColor(color)

Sets the border color of a Thing. Throws an error if there are fewer than 1 params or if the param is undefined.
Inherited From:
Source:
Parameters:
Name Type Description
color Color The resulting color of the Thing's border.

setBorderWidth(width)

Sets the width of a Thing's border. Throws an error if there is not 1 argument.
Inherited From:
Source:
Parameters:
Name Type Description
width number The resulting width of the Thing's border.

setColor(color)

Sets the color of a line.
Overrides:
Source:
Parameters:
Name Type Description
color Color Sets the color of the line.

setEndpoint(x, y)

Sets the *ending* point of the line.
Source:
Parameters:
Name Type Description
x number The x coordinate of the resulting ending point.
y number The y coordinate of the resulting ending point.

setFilled(filled)

Sets a Thing object to filled. Throws an error if an argument is not passed.
Inherited From:
Source:
Parameters:
Name Type Description
filled bool A boolean of whether or not Thing is filled.

setLineWidth(width)

Sets the width of the line.
Source:
Parameters:
Name Type Description
width number The resulting width of the line.

setPosition(x, y)

Sets the *starting* point of the line.
Overrides:
Source:
Parameters:
Name Type Description
x number The x coordinate of the resulting starting point.
y number The y coordinate of the resulting starting point.

setRotation(degrees, angleUnit)

Sets the rotation of a Thing in degrees. Throws an error if there are fewer than 1 params or if they are not numbers.
Inherited From:
Source:
Parameters:
Name Type Description
degrees number The degrees to rotate degrees.
angleUnit number Whether it is degrees or radians. Defaults to degrees.

setStartpoint(x, y)

Sets the *starting* point of the line.
Source:
Parameters:
Name Type Description
x number The x coordinate of the resulting ending point.
y number The y coordinate of the resulting ending point.

setType(type)

Sets a Thing object's type. Questionable of whether or not this method is used.
Inherited From:
Source:
Parameters:
Name Type Description
type type A type to set the Thing to.