mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-03-08 03:29:49 +01:00
fix: linting problem
This commit is contained in:
@@ -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]
|
||||||
|
|||||||
Reference in New Issue
Block a user