function tick(elapsed){
  // Filter the particle array from the previous tick()
  particles = particles.filter(d => d.current < d.path.getTotalLength());

  d3.selectAll('path.link')
    .each( function(d) { // DO NOT CONVERT TO ARROW FUNCTION, `this` will not bind properly, and you won't be able to access the SVG path properly
        // let elapsedF = f(elapsed);
        // let freqF= f((1-d.freq)*10);

        // if (elapsedF % freqF*10 === 0){}

        // the `x` limit also controls the frequency per second
        // for (let x = 0; x < 2; x++) {
          const offset = (Math.random() * nodeRadius - nodeRadius/2);

          // The higher the multiplied Math.random(), the less particles (because the probability is lower that there will be a decimal smaller than the d.freq)
          if (Math.random() * 15 < d.freq) {
          // if ( f(elapsed/1000) % f((1-d.freq)*100) === 0 ){
                      
            const length = this.getTotalLength();

            // Update the particle array
            particles.push({
              link: d,
              time: elapsed,
              offset,
              path: this,
              length,
              animateTime: length,
              speed: .5
            });
          // }
        }
      });

  // With updated particle array and elapsed time, draw those particles on the canvas
  drawParticlePathOnCanvas(elapsed);
}
// d3.timer passes elapsed time as first argument
d3.timer passes elapsed time as first argument
d3 . timer passes elapsed time as first argument
function tick(elapsed){
  particles = particles.filter(d => d.current < d.path.getTotalLength());
  d3.selectAll('path.link')
    .each( function(d) { 
          const offset = (Math.random() * nodeRadius - nodeRadius/2);
          if (Math.random() * 15 < d.freq) {
            const length = this.getTotalLength();
            particles.push({
              link: d,
              time: elapsed,
              offset,
              path: this,
              length,
              animateTime: length,
              speed: .5
            });
        }
      });
  drawParticlePathOnCanvas(elapsed);
}
function tick ( elapsed ) { particles = particles . filter ( d => d . current < d . path . getTotalLength ( ) ) ; d3 . selectAll ( 'path.link' ) . each ( function ( d ) { const offset = ( Math . random ( ) * nodeRadius - nodeRadius / 2 ) ; if ( Math . random ( ) * 15 < d . freq ) { const length = this . getTotalLength ( ) ; particles . push ( { link : d , time : elapsed , offset , path : this , length , animateTime : length , speed : .5 } ) ; } } ) ; drawParticlePathOnCanvas ( elapsed ) ; }
d3.timer passes elapsed time as first argument
d3 . timer passes elapsed time as first argument
// Filter the particle array from the previous tick() // DO NOT CONVERT TO ARROW FUNCTION, `this` will not bind properly, and you won't be able to access the SVG path properly // let elapsedF = f(elapsed); // let freqF= f((1-d.freq)*10); // if (elapsedF % freqF*10 === 0){} // the `x` limit also controls the frequency per second // for (let x = 0; x < 2; x++) { // The higher the multiplied Math.random(), the less particles (because the probability is lower that there will be a decimal smaller than the d.freq) // if ( f(elapsed/1000) % f((1-d.freq)*100) === 0 ){ // Update the particle array // } // With updated particle array and elapsed time, draw those particles on the canvas