From 0175d37d09abc5f5ef8b4b63f0e8781b4078509d Mon Sep 17 00:00:00 2001 From: Logan Matheny Date: Wed, 10 Jan 2024 20:03:02 -0500 Subject: [PATCH] Revert "Fix Light Mode Bug" --- src/components/WhiteBoard/WhiteBoard.js | 65 +++++++++++-------------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/src/components/WhiteBoard/WhiteBoard.js b/src/components/WhiteBoard/WhiteBoard.js index 02216b2..efb5b94 100644 --- a/src/components/WhiteBoard/WhiteBoard.js +++ b/src/components/WhiteBoard/WhiteBoard.js @@ -16,9 +16,7 @@ function WhiteBoard() { var remoteLastY = 0; var isErasing = false; const defaultColor = "#000000"; - - const backgroundColor = appColor === "light" ? "white" : "#8d8c8d"; - + const backgroundColor = appColor === "light" ? "white" : "#636363"; function received(data) { const jsonData = JSON.parse(data.data); @@ -47,9 +45,7 @@ function WhiteBoard() { function toggleEraser() { isErasing = !isErasing; context.strokeStyle = isErasing ? backgroundColor : defaultColor; - - context.lineWidth = 25 - + context.lineWidth = 25; } function drawRemoteData(x, y) { @@ -98,9 +94,9 @@ function WhiteBoard() { socket.addEventListener("message", received); - - document.getElementById('eraserButton').addEventListener('click', toggleEraser); - + document + .getElementById("eraserButton") + .addEventListener("click", toggleEraser); return () => { window.addEventListener("resize", updateCanvasSize); @@ -113,49 +109,49 @@ function WhiteBoard() { function startDrawing(event) { isDrawing = true; - const canvas = document.getElementById('canvas'); + const canvas = document.getElementById("canvas"); var mousePos = getMousePos(canvas, event); - if (!isErasing) { context.strokeStyle = document.getElementById("colorPicker").value; context.lineWidth = document.getElementById("lineSize").value; } - lastX = mousePos.x; lastY = mousePos.y; lastSent = Date.now(); - sendDrawData(mousePos.x, mousePos.y, "start", context.strokeStyle, context.lineWidth); - } + sendDrawData( + mousePos.x, + mousePos.y, + "start", + context.strokeStyle, + context.lineWidth + ); + } function stopDrawing(event) { isDrawing = false; - const canvas = document.getElementById('canvas'); + const canvas = document.getElementById("canvas"); var mousePos = getMousePos(canvas, event); - lastX = mousePos.x; lastY = mousePos.y; lastSent = Date.now(); sendDrawData(mousePos.x, mousePos.y, "stop"); } - function draw(event) { if (!isDrawing) return; - - const canvas = document.getElementById('canvas'); + + const canvas = document.getElementById("canvas"); var mousePos = getMousePos(canvas, event); - + if (Date.now() - lastSent > 10) { sendDrawData(mousePos.x, mousePos.y, "drawing"); lastSent = Date.now(); } drawData(mousePos.x, mousePos.y); - - } - + } function drawData(x, y) { context.lineJoin = "round"; @@ -183,12 +179,10 @@ function WhiteBoard() { } function getMousePos(canvas, evt) { - - var rect = canvas.getBoundingClientRect(); + var rect = canvas.getBoundingClientRect(); return { x: evt.clientX - rect.left, - y: evt.clientY - rect.top - + y: evt.clientY - rect.top, }; } @@ -197,26 +191,23 @@ function WhiteBoard() {
Whiteboard
- -
- +
-
- +
+
+ +
- - +
); - } export default WhiteBoard;