fix: linting problem

This commit is contained in:
2026-02-24 19:02:37 +01:00
parent 244692d8f9
commit c397f40239

View File

@@ -66,7 +66,23 @@ export default function DrawingCanvas({ initialDrawing, onSave, onClear }: Drawi
}, [initialDrawing]) }, [initialDrawing])
useEffect(() => { useEffect(() => {
redrawCanvas() const canvas = canvasRef.current
if (!canvas || !contextRef.current) return
const context = contextRef.current
context.clearRect(0, 0, canvas.width, canvas.height)
drawingHistory.forEach(stroke => {
if (stroke.points.length === 0) return
context.beginPath()
context.strokeStyle = stroke.color
context.lineWidth = stroke.thickness
context.moveTo(stroke.points[0].x, stroke.points[0].y)
stroke.points.forEach(point => {
context.lineTo(point.x, point.y)
})
context.stroke()
})
}, [drawingHistory]) }, [drawingHistory])
const getMousePos = (event: React.MouseEvent) => { const getMousePos = (event: React.MouseEvent) => {
@@ -125,26 +141,6 @@ export default function DrawingCanvas({ initialDrawing, onSave, onClear }: Drawi
contextRef.current?.closePath() contextRef.current?.closePath()
} }
const redrawCanvas = () => {
const canvas = canvasRef.current
if (!canvas || !contextRef.current) return
const context = contextRef.current
context.clearRect(0, 0, canvas.width, canvas.height)
drawingHistory.forEach(stroke => {
if (stroke.points.length === 0) return
context.beginPath()
context.strokeStyle = stroke.color
context.lineWidth = stroke.thickness
context.moveTo(stroke.points[0].x, stroke.points[0].y)
stroke.points.forEach(point => {
context.lineTo(point.x, point.y)
})
context.stroke()
})
}
const handleUndo = () => { const handleUndo = () => {
setDrawingHistory(prevHistory => { setDrawingHistory(prevHistory => {
const newHistory = [...prevHistory] const newHistory = [...prevHistory]