Skip to content

Commit

Permalink
shapes/geometry: add line_points
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-pH committed Feb 20, 2024
1 parent cb555af commit cf88937
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/shapes/shapes_geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,18 @@ export function line_extend(l : Diagram, len1 : number, len2 : number) : Diagram
newl.path.points = [p0_new, p1_new];
return newl;
}

/**
* Get the points of a line
* @param l a line Diagram
* @returns the two points of the line
*/
export function line_points(l : Diagram) : [Vector2, Vector2] {
let tags = l.tags;
if (!tags.includes('line')) return [V2(0,0), V2(0,0)];
if (l.path == undefined) return [V2(0,0), V2(0,0)];

let p0 = l.path.points[0];
let p1 = l.path.points[1];
return [p0, p1];
}

0 comments on commit cf88937

Please sign in to comment.