Builds for
1 pipeline
failed
in
1 minute 22 seconds
clearCanvas 콜백 추가
Showing
1 changed file
with
9 additions
and
0 deletions
... | @@ -38,6 +38,15 @@ export const Canvas: React.FC = () => { | ... | @@ -38,6 +38,15 @@ export const Canvas: React.FC = () => { |
38 | } | 38 | } |
39 | }, []); | 39 | }, []); |
40 | 40 | ||
41 | + const clearCanvas = useCallback(() => { | ||
42 | + if (canvasRef.current) { | ||
43 | + const context = canvasRef.current.getContext('2d'); | ||
44 | + if (context) { | ||
45 | + context.clearRect(0, 0, canvasRef.current.width, canvasRef.current.height); | ||
46 | + } | ||
47 | + } | ||
48 | + }, []); | ||
49 | + | ||
41 | const startPaint = useCallback((event: MouseEvent) => { | 50 | const startPaint = useCallback((event: MouseEvent) => { |
42 | const coordinates = getCoordinates(event); | 51 | const coordinates = getCoordinates(event); |
43 | if (coordinates) { | 52 | if (coordinates) { | ... | ... |
-
Please register or login to post a comment