From f2341e01746c06ef5a7a09610d4559361b50a7f7 Mon Sep 17 00:00:00 2001 From: Christian Liebel Date: Thu, 16 May 2024 15:49:54 +0200 Subject: [PATCH] fix(tools): fix TypeScript errors after migration to TS 5 --- src/tools/brush.ts | 10 ++++------ src/tools/ellipse.ts | 13 ++----------- src/tools/line.ts | 5 ++--- src/tools/rectangle.ts | 3 --- 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/tools/brush.ts b/src/tools/brush.ts index 230c82ea..a6faf1be 100644 --- a/src/tools/brush.ts +++ b/src/tools/brush.ts @@ -74,18 +74,18 @@ export class BrushTool implements Tool { if (type === 'forward-diagonal') { if (posDiff && posDiff.y !== 0) { const xCorr = posDiff.y === -1 && posDiff.x === -1 ? x : x - 1; - this.drawForwardLine(xCorr, yCorr, diff, correction, size, context); + this.drawForwardLine(xCorr, yCorr, diff, correction, context); } - this.drawForwardLine(x, y, diff, correction, size, context); + this.drawForwardLine(x, y, diff, correction, context); return; } if (type === 'backward-diagonal') { if (posDiff && posDiff.y !== 0) { const xCorr = posDiff.y === -1 && posDiff.x === 1 ? x : x + 1; - this.drawBackwardLine(xCorr, yCorr, diff, correction, size, context); + this.drawBackwardLine(xCorr, yCorr, diff, correction, context); } - this.drawBackwardLine(x, y, diff, correction, size, context); + this.drawBackwardLine(x, y, diff, correction, context); return; } @@ -107,7 +107,6 @@ export class BrushTool implements Tool { y: number, diff: number, correction: number, - size: number, context: CanvasRenderingContext2D, ): void { const start = { x: x - diff, y: y + diff + correction }; @@ -122,7 +121,6 @@ export class BrushTool implements Tool { y: number, diff: number, correction: number, - size: number, context: CanvasRenderingContext2D, ): void { const start = { x: x - diff, y: y - diff }; diff --git a/src/tools/ellipse.ts b/src/tools/ellipse.ts index 89744454..a8d8d841 100644 --- a/src/tools/ellipse.ts +++ b/src/tools/ellipse.ts @@ -19,15 +19,7 @@ export class EllipseTool implements Tool { color: ToolColor, ): void { if (canvas && previewContext) { - this.drawEllipse( - x, - y, - fillStyle, - color, - canvas, - previewContext, - previewContext, - ); + this.drawEllipse(x, y, fillStyle, color, previewContext, previewContext); } } @@ -38,7 +30,7 @@ export class EllipseTool implements Tool { color: ToolColor, ): void { if (canvas && context && previewContext) { - this.drawEllipse(x, y, fillStyle, color, canvas, context, previewContext); + this.drawEllipse(x, y, fillStyle, color, context, previewContext); } } @@ -47,7 +39,6 @@ export class EllipseTool implements Tool { y: number, fillStyle: FillStyle, color: ToolColor, - canvas: HTMLCanvasElement, targetContext: CanvasRenderingContext2D, previewContext: CanvasRenderingContext2D, ): void { diff --git a/src/tools/line.ts b/src/tools/line.ts index 162d4099..8367ed4f 100644 --- a/src/tools/line.ts +++ b/src/tools/line.ts @@ -26,7 +26,7 @@ export class LineTool implements Tool { { previewContext, canvas, lineWidth }: DrawingContext, ): void { if (canvas && previewContext) { - this.drawLine(x, y, previewContext, previewContext, canvas, lineWidth); + this.drawLine(x, y, previewContext, previewContext, lineWidth); } } @@ -36,7 +36,7 @@ export class LineTool implements Tool { { previewContext, context, canvas, lineWidth }: DrawingContext, ): void { if (previewContext && context && canvas) { - this.drawLine(x, y, context, previewContext, canvas, lineWidth); + this.drawLine(x, y, context, previewContext, lineWidth); } } @@ -45,7 +45,6 @@ export class LineTool implements Tool { y: number, targetContext: CanvasRenderingContext2D, previewContext: CanvasRenderingContext2D, - canvas: HTMLCanvasElement, lineWidth: number, ): void { clearContext(previewContext); diff --git a/src/tools/rectangle.ts b/src/tools/rectangle.ts index 556fc0b9..d981b636 100644 --- a/src/tools/rectangle.ts +++ b/src/tools/rectangle.ts @@ -25,7 +25,6 @@ export class RectangleTool implements Tool { previewContext, fillStyle, lineWidth, - canvas, color, ); } @@ -45,7 +44,6 @@ export class RectangleTool implements Tool { previewContext, fillStyle, lineWidth, - canvas, color, ); } @@ -58,7 +56,6 @@ export class RectangleTool implements Tool { previewContext: CanvasRenderingContext2D, fillStyle: { fill: boolean; stroke: boolean }, lineWidth: number, - canvas: HTMLCanvasElement, color: ToolColor, ): void { clearContext(previewContext);