1

When you draw too fast on a canvas then you will see gaps, see my working example here.

My code is:

let canvas = document.getElementById('drawing-canvas');
function drawingPen(e) {
  const canvasSizes = canvas.width / cellSize;

  canvasCtx.fillStyle = '#000000';

const currentX = Math.floor(e.offsetX / canvasSizes) * canvasSizes;
const currentY = Math.floor(e.offsetY / canvasSizes) * canvasSizes;

What am I doing wrong, why does the above code result to so many gaps when drawing fast?

Kate Orlova
  • 3,225
  • 5
  • 11
  • 35
ivanRunec
  • 11
  • 1
  • Welcome to SO. There is no drawing happening in the code you presented. – spender Jun 18 '19 at 01:46
  • as the mouse moves even though when moving fast it does not supply to you every in between location you know those since you know the before and after locations so just have your code fill in the missing data locations – Scott Stensland Jun 18 '19 at 14:55

0 Answers0