-1

I'm looking for a pure JS library that allows to draw the mouse trail, but I cannot find anything pure but using canvas. Is there is a reason for that it could not be achieved? I'm on the wrong thoughts?

2
  • closed? really?
    – Manu
    Mar 12, 2013 at 8:04
  • Can someone who voted to close this explain to Manu why. See the comment on my answer.
    – Sam
    Mar 13, 2013 at 12:28

1 Answer 1

6

The reason you require Canvas is because the HTML DOM is an object model. There is not one element in HTML that allows arbitrary drawing (such as lines, per pixel, non-rectangular shapes) hence the requirement for using Canvas.

Is there is a reason that I could not be achieved?

You could achieve this by creating an image at intervals of mouse movement that is a circle with a transparent background, for example, to simulate this. But canvas makes much more sense.

11
  • so, could I use the .mousemove jQ event to track every movement of the mouse on the document with event.pageX and event.pageY and set the values to a css position of a div?
    – Manu
    Mar 11, 2013 at 22:53
  • Yes, create and append an element to the DOM and set it to position: absolute, setting the position to pageX/Y.
    – Sam
    Mar 11, 2013 at 22:58
  • Great! You rock. It would be great if you could post it in jsfiddle or something like that, becasue I'm trying this: jsfiddle.net/4y2Ue, but it does not work, and I'm entering on a self-destructive spiral.
    – Manu
    Mar 11, 2013 at 23:06
  • @Manu: you're missing some + signs in your string concatenation, ..top='posY';left.. should be ..top='+posY+';left.. Mar 11, 2013 at 23:32
  • 1
    @Manu Stackoverflow.com will help with implementation concerns; programmers isn't for implementation between programmers and SO. I will try and look at it but I am very busy, you may get a quicker result on Stack Overflow.
    – Sam
    Mar 12, 2013 at 22:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.