vishalbakshi commited on
Commit
22680b4
·
verified ·
1 Parent(s): cf74104

deploy at 2024-08-24 21:23:26.835073

Browse files
Files changed (1) hide show
  1. digitDrawer.js +12 -3
digitDrawer.js CHANGED
@@ -28,7 +28,11 @@ function initializeGrid() {
28
 
29
  function startDrawing(e) {
30
  isDrawing = true;
31
- draw(e);
 
 
 
 
32
  }
33
 
34
  function stopDrawing() {
@@ -38,14 +42,19 @@ function stopDrawing() {
38
 
39
  function draw(e) {
40
  if (!isDrawing) return;
 
 
 
 
 
41
  ctx.lineWidth = 20;
42
  ctx.lineCap = 'round';
43
  ctx.strokeStyle = '#000';
44
 
45
- ctx.lineTo(e.clientX - canvas.offsetLeft, e.clientY - canvas.offsetTop);
46
  ctx.stroke();
47
  ctx.beginPath();
48
- ctx.moveTo(e.clientX - canvas.offsetLeft, e.clientY - canvas.offsetTop);
49
 
50
  // Check if it's time for a new prediction
51
  const currentTime = Date.now();
 
28
 
29
  function startDrawing(e) {
30
  isDrawing = true;
31
+ const rect = canvas.getBoundingClientRect();
32
+ const x = e.clientX - rect.left;
33
+ const y = e.clientY - rect.top;
34
+ ctx.beginPath();
35
+ ctx.moveTo(x, y);
36
  }
37
 
38
  function stopDrawing() {
 
42
 
43
  function draw(e) {
44
  if (!isDrawing) return;
45
+
46
+ const rect = canvas.getBoundingClientRect();
47
+ const x = e.clientX - rect.left;
48
+ const y = e.clientY - rect.top;
49
+
50
  ctx.lineWidth = 20;
51
  ctx.lineCap = 'round';
52
  ctx.strokeStyle = '#000';
53
 
54
+ ctx.lineTo(x, y);
55
  ctx.stroke();
56
  ctx.beginPath();
57
+ ctx.moveTo(x, y);
58
 
59
  // Check if it's time for a new prediction
60
  const currentTime = Date.now();