Line2D

external class Line2D : JsAny

Constructors

Link copied to clipboard
constructor()

Constructs and initializes a Line with coordinates (0, 0) -> (0, 0).

constructor(p1: Point2D, p2: Point2D)

Constructs and initializes a Line2D from the specified Point2D objects.

constructor(x1: double, y1: double, x2: double, y2: double)

Constructs and initializes a Line2D from the specified coordinates.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
var x1: double

The X coordinate of the start point of the line segment.

Link copied to clipboard
var x2: double

The X coordinate of the end point of the line segment.

Link copied to clipboard
var y1: double

The Y coordinate of the start point of the line segment.

Link copied to clipboard
var y2: double

The Y coordinate of the end point of the line segment.

Functions

Link copied to clipboard
fun clone(): Line2D?

Creates a new object of the same class as this object.

Link copied to clipboard

Tests if a given Point2D is inside the boundary of this Line2D. This method is required to implement the {@link Shape} interface, but in the case of Line2D objects it always returns false since a line contains no area.

Tests if the interior of this Line2D entirely contains the specified Rectangle2D. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.

Tests if a specified coordinate is inside the boundary of this Line2D. This method is required to implement the {@link Shape} interface, but in the case of Line2D objects it always returns false since a line contains no area.

fun contains(x: double, y: double, w: double, h: double): Boolean

Tests if the interior of this Line2D entirely contains the specified set of rectangular coordinates. This method is required to implement the Shape interface, but in the case of Line2D objects it always returns false since a line contains no area.

Link copied to clipboard

{@inheritDoc}

Link copied to clipboard
fun getP1(): Point2D

{@inheritDoc}

Link copied to clipboard
fun getP2(): Point2D

{@inheritDoc}

Link copied to clipboard
fun getX1(): double

{@inheritDoc}

Link copied to clipboard
fun getX2(): double

{@inheritDoc}

Link copied to clipboard
fun getY1(): double

{@inheritDoc}

Link copied to clipboard
fun getY2(): double

{@inheritDoc}

Link copied to clipboard
Link copied to clipboard

Returns the distance from a Point2D to this line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by this Line2D. If the specified point intersects the line, this method returns 0.0.

Returns the distance from a point to this line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by this Line2D. If the specified point intersects the line, this method returns 0.0.

Link copied to clipboard

Returns the square of the distance from a specified Point2D to this line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by this Line2D. If the specified point intersects the line, this method returns 0.0.

Returns the square of the distance from a point to this line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by this Line2D. If the specified point intersects the line, this method returns 0.0.

Link copied to clipboard
fun relativeCCW(px: double, py: double): int

Returns an indicator of where the specified point {@code (px,py)} lies with respect to this line segment. See the method comments of {@link #relativeCCW(double, double, double, double, double, double)} to interpret the return value.

Link copied to clipboard
fun setLine(l: Line2D)

Sets the location of the end points of this Line2D to the same as those end points of the specified Line2D.

fun setLine(p1: Point2D, p2: Point2D)

Sets the location of the end points of this Line2D to the specified Point2D coordinates.

fun setLine(x1: double, y1: double, x2: double, y2: double)

Sets the location of the end points of this Line2D to the specified double coordinates.