Skip to content

Commit

Permalink
feat: add line_drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
Lampese committed Jul 23, 2023
1 parent c563920 commit 316d738
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,16 @@ function line(a: Vec3, b: Vec3, acc: number): Space {
);
}

function triangle(p1: Vec3, p2: Vec3, p3: Vec3, acc: number): Space {
const base = line(p1, p2, acc);
function triangle(
p1: Vec3,
p2: Vec3,
p3: Vec3,
acc: number,
line_drawer: (a: Vec3, b: Vec3, acc?: number) => Space = line
): Space {
const base = line_drawer(p1, p2, acc);

const fill = base.flatMap((point) => line(point, p3, acc));
const fill = base.flatMap((point) => line_drawer(point, p3, acc));

return [...base, ...fill];
}
Expand Down

0 comments on commit 316d738

Please sign in to comment.