File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import Canvas from "./components/Canvas";
10
10
import Menu from "./components/Menu" ;
11
11
import EraserCursor from "./components/EraserCursor" ;
12
12
import { useRecoilValue , useRecoilState } from "recoil" ;
13
- import { eraserState , cursorPosition } from "./atoms" ;
13
+ import { eraserState , cursorPosition , canvasColors } from "./atoms" ;
14
14
15
15
function App ( ) {
16
16
const [ showMenu , setShowMenu ] = useState ( false ) ;
@@ -21,6 +21,7 @@ function App() {
21
21
const [ startY , setStartY ] = useState ( 0 ) ;
22
22
const [ isDrawing , setIsDrawing ] = useState ( false ) ;
23
23
const [ penColor , setPenColor ] = useState ( "#000000" ) ;
24
+ const canvasColor = useRecoilValue ( canvasColors ) ;
24
25
25
26
function toggleMenu ( ) {
26
27
setShowMenu ( ! showMenu ) ;
@@ -34,8 +35,8 @@ function App() {
34
35
ctx . moveTo ( sx , sy ) ;
35
36
ctx . lineTo ( ex , ey ) ;
36
37
ctx . lineCap = "round" ;
37
- ctx . lineWidth = lineWidth ;
38
- ctx . strokeStyle = penColor ;
38
+ ctx . lineWidth = eraserMode ? 40 : lineWidth ;
39
+ ctx . strokeStyle = eraserMode ? canvasColor : penColor ;
39
40
ctx . stroke ( ) ;
40
41
}
41
42
@@ -161,4 +162,4 @@ function App() {
161
162
) ;
162
163
}
163
164
164
- export default App ;
165
+ export default App ;
You can’t perform that action at this time.
0 commit comments