Skip to content

Path beta ​

Class of @v12-engine/engine

ts
export declare class Path

A 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 ​

ts
constructor(
    points: readonly Vec2[], 
    width: number);

Constructs a new instance of the Path class

at ​

ts
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 ​

ts
contains(point: Vec2): boolean;

Whether a point is on the path: no more than half its width from its middle

containsCell ​

ts
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 ​

ts
distanceTo(point: Vec2): number;

How far a point is from the middle of the path

end ​

ts
get end(): Vec2;

A copy of the path's last point

length ​

ts
get length(): number;

How long it is, from its first point to its last

nearest ​

ts
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 ​

ts
readonly points: readonly Vec2[];

Its points, in order. Not to be changed: the path works out its length from them once

start ​

ts
get start(): Vec2;

A copy of the path's first point

width ​

ts
readonly width: number;

How wide it is: a point is on it when it is no more than half of this from its middle