P
P
ProgerSoft2019-07-11 17:01:53
JavaScript
ProgerSoft, 2019-07-11 17:01:53

HTML5 Canvas - LineTo?

It is necessary for me, that in Canvas' the line from a point 50, 50to the cursor was drawn. Here is the JS code:

$(canv).mousemove(evt => {
  ctx.fillStyle = '#fff';
  ctx.fillRect(0, 0, canv.width, canv.height);
  
  ctx.strokeStyle = '#000';
  ctx.beginPath();
  ctx.moveTo(50, 50);
  ctx.lineTo(evt.clientX, evt.clientY);
  ctx.stroke();
});

But it doesn't work...
Can you help?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2019-07-11
@rPman

https://api.jquery.com/mousemove/
you would at least for the test output to the log what is inside evt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question