Path beta
Class of @v12-engine/engine
export declare class PathA line on the map, through points in order, with a width: a road, a patrol route, the way a wave walks. What the rules ask of one a game would otherwise write each time: how long it is, where along it something is, how far a point is from it, whether a point is on it
Members
constructor
constructor(
points: readonly Vec2[],
width: number);Constructs a new instance of the Path class
at
at(distance: number): Spot;Where on the path something is that has gone distance along it from its start, facing the way it goes. Before the start is the start, past the end the end
contains
contains(point: Vec2): boolean;Whether a point is on the path: no more than half its width from its middle
containsCell
containsCell(cx: number, cz: number): boolean;Whether the middle of a cell of the map is on the path: what it paints, and keeps clear
distanceTo
distanceTo(point: Vec2): number;How far a point is from the middle of the path
end
get end(): Vec2;A copy of the path's last point
length
get length(): number;How long it is, from its first point to its last
nearest
nearest(point: Vec2): {
at: Vec2;
distance: number;
along: number;
};The nearest point of its middle line to a point, and how far along the path that is
points
readonly points: readonly Vec2[];Its points, in order. Not to be changed: the path works out its length from them once
start
get start(): Vec2;A copy of the path's first point
width
readonly width: number;How wide it is: a point is on it when it is no more than half of this from its middle