Answer the question
In order to leave comments, you need to log in
How to implement an animated mouse trail using canvas?
I'm looking for a similar implementation like here hakim.se/experiments/html5/sinuous/01/# I'm
interested in the mouse trail line. The task is to see how it was done and do it a little differently.
Answer the question
In order to leave comments, you need to log in
1. While moving the mouse, fill the stack (for example, 20 cells) with its coordinates. Throw out very close coordinates.
2. Each frame we take the coordinates in the stack and draw a line on them ( line by points, eng ).
There seems to be nothing complicated.
UPD: As an optimization, you can not completely update the line, but draw it. But this is implemented a little more complicated.
UPD2: In the game itself, according to your link, the coordinates in the stack are also shifted in the direction of particle movement every game cycle.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question