2021-11-27 04:36:37 +00:00
|
|
|
/// <reference path="vector.ts" />
|
|
|
|
/// <reference path="shapeStyle.ts" />
|
2021-11-26 18:43:48 +00:00
|
|
|
|
2021-11-27 04:36:37 +00:00
|
|
|
function line(ctx: CanvasRenderingContext2D, from: Vector2D , to: Vector2D, style: ShapeStyle = new ShapeStyle())
|
2021-11-26 18:43:48 +00:00
|
|
|
{
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.moveTo(from.x, from.y);
|
|
|
|
ctx.lineTo(to.x, to.y);
|
|
|
|
|
|
|
|
ctx.lineWidth = style.strokeWidth;
|
|
|
|
ctx.strokeStyle = style.strokeColor;
|
|
|
|
ctx.stroke();
|
|
|
|
}
|
|
|
|
|
2021-11-27 04:36:37 +00:00
|
|
|
function circle(ctx: CanvasRenderingContext2D, center: Vector2D, radius: number, style: ShapeStyle = new ShapeStyle())
|
2021-11-26 18:43:48 +00:00
|
|
|
{
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI, false);
|
|
|
|
|
|
|
|
ctx.fillStyle = style.fillColor;
|
|
|
|
ctx.fill();
|
|
|
|
|
|
|
|
ctx.lineWidth = style.strokeWidth;
|
|
|
|
ctx.strokeStyle = style.strokeColor;
|
|
|
|
ctx.stroke();
|
|
|
|
}
|