Skip to content

Commit

Permalink
fix(tools): fix TypeScript errors after migration to TS 5
Browse files Browse the repository at this point in the history
  • Loading branch information
christianliebel committed May 16, 2024
1 parent 91f7f6c commit f2341e0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 23 deletions.
10 changes: 4 additions & 6 deletions src/tools/brush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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 };
Expand All @@ -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 };
Expand Down
13 changes: 2 additions & 11 deletions src/tools/ellipse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -47,7 +39,6 @@ export class EllipseTool implements Tool {
y: number,
fillStyle: FillStyle,
color: ToolColor,
canvas: HTMLCanvasElement,
targetContext: CanvasRenderingContext2D,
previewContext: CanvasRenderingContext2D,
): void {
Expand Down
5 changes: 2 additions & 3 deletions src/tools/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -45,7 +45,6 @@ export class LineTool implements Tool {
y: number,
targetContext: CanvasRenderingContext2D,
previewContext: CanvasRenderingContext2D,
canvas: HTMLCanvasElement,
lineWidth: number,
): void {
clearContext(previewContext);
Expand Down
3 changes: 0 additions & 3 deletions src/tools/rectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export class RectangleTool implements Tool {
previewContext,
fillStyle,
lineWidth,
canvas,
color,
);
}
Expand All @@ -45,7 +44,6 @@ export class RectangleTool implements Tool {
previewContext,
fillStyle,
lineWidth,
canvas,
color,
);
}
Expand All @@ -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);
Expand Down

0 comments on commit f2341e0

Please sign in to comment.