Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

closed as not a real question by Jim G., Martijn Pieters, MichaelT, gnat, BЈовић Mar 12 '13 at 8:03

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

closed? really? – Manu Mar 12 '13 at 8:04
Can someone who voted to close this explain to Manu why. See the comment on my answer. – Sam Mar 13 '13 at 12:28
up vote 6 down vote accepted

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.

share|improve this answer
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 '13 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 '13 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:, but it does not work, and I'm entering on a self-destructive spiral. – Manu Mar 11 '13 at 23:06
@Manu: you're missing some + signs in your string concatenation,'posY';left.. should be'+posY+';left.. – Carson63000 Mar 11 '13 at 23:32
@Manu 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 '13 at 22:20

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