Skip to content

Commit 724dfe7

Browse files
authored
Merge pull request #35 from apsinghdev/Feat/eraser
Feat/eraser
2 parents 51abbd7 + f19bb04 commit 724dfe7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

client/src/App.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Canvas from "./components/Canvas";
1010
import Menu from "./components/Menu";
1111
import EraserCursor from "./components/EraserCursor";
1212
import { useRecoilValue, useRecoilState } from "recoil";
13-
import { eraserState, cursorPosition } from "./atoms";
13+
import { eraserState, cursorPosition, canvasColors } from "./atoms";
1414

1515
function App() {
1616
const [showMenu, setShowMenu] = useState(false);
@@ -21,6 +21,7 @@ function App() {
2121
const [startY, setStartY] = useState(0);
2222
const [isDrawing, setIsDrawing] = useState(false);
2323
const [penColor, setPenColor] = useState("#000000");
24+
const canvasColor = useRecoilValue(canvasColors);
2425

2526
function toggleMenu() {
2627
setShowMenu(!showMenu);
@@ -34,8 +35,8 @@ function App() {
3435
ctx.moveTo(sx, sy);
3536
ctx.lineTo(ex, ey);
3637
ctx.lineCap = "round";
37-
ctx.lineWidth = lineWidth;
38-
ctx.strokeStyle = penColor;
38+
ctx.lineWidth = eraserMode ? 40 : lineWidth;
39+
ctx.strokeStyle = eraserMode ? canvasColor : penColor;
3940
ctx.stroke();
4041
}
4142

@@ -161,4 +162,4 @@ function App() {
161162
);
162163
}
163164

164-
export default App;
165+
export default App;

0 commit comments

Comments
 (0)