Working version of train following spline path
This commit is contained in:
16
drawing/circle.ts
Normal file
16
drawing/circle.ts
Normal 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
1
drawing/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { drawCircle, fillCircle } from './circle.ts'
|
6
drawing/line.ts
Normal file
6
drawing/line.ts
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user