I am trying to create a streamline wind map using data from seven weather stations. I am trying to have the same type of map is this animation or this animation.
I have read articles online that say how it works. It is quoted below.
Typically, such a visualization in the browser relies on the Canvas 2D API and roughly works like this:
- Generate an array of random particle positions on screen and draw the particles.
- For each particle, query the wind data to get the particle speed in its current location, and move it accordingly.
- Reset a small portion of particles to a random position. This makes sure that areas the wind blows away from never become fully empty.
- Fade the current screen a bit and draw newly positioned particles on top.
I am trying to achieve this, but I dont understand how the animations did the following...
So, how did they do that? Any advice is greatly appreciated for this novice programmer.
Thank you.
After significantly extensive research, I found a method to achieve what I was looking for.
ctx.beginPath();
ctx.fillStyle = 'rgba(255, 255, 255, 0.25)';
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
ctx.closePath();
This draws an opaque layer over the canvas and allowed for the line to shorten.