Skip to content

Commit 7840bf1

Browse files
committed
fixed whiteboard bug
1 parent bac23cc commit 7840bf1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/IDE.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,11 @@ export default function IDE({ docId, modal, toggleModal, cpp, setcpp, java, setj
420420

421421
const drawLine = (x0, y0, x1, y1, color, width, emit) => {
422422
context.beginPath();
423+
context.strokeStyle = color;
423424
context.moveTo(x0, y0);
424425
context.lineTo(x1, y1);
425-
context.strokeStyle = color;
426+
console.log(color);
427+
console.log(context.strokeStyle);
426428
context.lineWidth = width;
427429
context.stroke();
428430
context.closePath();
@@ -432,13 +434,15 @@ export default function IDE({ docId, modal, toggleModal, cpp, setcpp, java, setj
432434
const h = canvas.height;
433435
// console.log(w, h, window.width, window.height);
434436

435-
437+
438+
setPencilColor(current.color);
439+
436440
socket.emit('drawing', {
437441
x0: x0 / w,
438442
y0: y0 / h,
439443
x1: x1 / w,
440444
y1: y1 / h,
441-
pencilColor,
445+
color: current.color,
442446
width
443447
});
444448
};
@@ -500,6 +504,7 @@ export default function IDE({ docId, modal, toggleModal, cpp, setcpp, java, setj
500504
const onDrawingEvent = (data) => {
501505
const w = canvas.width;
502506
const h = canvas.height;
507+
console.log(data.color);
503508
drawLine(data.x0 * w, data.y0 * h, data.x1 * w, data.y1 * h, data.color, data.width);
504509
}
505510
socket.on('drawing', onDrawingEvent);

0 commit comments

Comments
 (0)