Working version of train following spline path

This commit is contained in:
Emma
2023-02-07 08:36:58 -07:00
commit f1c991bd3e
17 changed files with 2350 additions and 0 deletions

16
drawing/circle.ts Normal file
View File

@@ -0,0 +1,16 @@
import { Constants } from "../math/constants.ts";
import { Vector } from "../math/vector.ts";
const circle = (ctx: CanvasRenderingContext2D, center: Vector, radius: number) => {
ctx.beginPath();
ctx.arc(center.x, center.y, radius, 0, Constants.TWO_PI);
}
export const drawCircle = (ctx: CanvasRenderingContext2D, center: Vector, radius: number) => {
circle(ctx, center, radius);
ctx.stroke();
}
export const fillCircle = (ctx: CanvasRenderingContext2D, center: Vector, radius: number) => {
circle(ctx, center, radius);
ctx.fill();
}

1
drawing/index.ts Normal file
View File

@@ -0,0 +1 @@
export { drawCircle, fillCircle } from './circle.ts'

6
drawing/line.ts Normal file
View File

@@ -0,0 +1,6 @@
export const drawLine = (ctx: CanvasRenderingContext2D, x1:number, y1:number, x2:number, y2: number) => {
ctx.beginPath();
ctx.moveTo(x1,y1);
ctx.lineTo(x2,y2);
ctx.stroke();
}