function animate() {

    ctx.globalCompositeOperation = 'destination-over';
    ctx.clearRect(0, 0, canvas.width, canvas.height);

    ctx.strokeStyle = "black";
    ctx.save();

    canvas.width = win_width;
    canvas.height = win_height;

    //this if test is used to account for user changes in number of particles between animation frames
    if (particle_array.length < max_particle) {
        particle_generator(particle_array.length, max_particle);
    }
   
    //when the magnet flag is true, a yellow arc is drawn at the user position and the speed of particles traveling is lowered
    switch (magnet_flag) {
        case true:
            var grav_constant = 2;
            ctx.beginPath();
            ctx.strokeStyle = "yellow";
            ctx.arc(mouse_x,mouse_y, 12, 0, Math.PI*2, true);
            ctx.closePath();
            ctx.stroke();

            speed = (1/500);

            particle_mover(speed);
            break;
        
        //when the user is not magnetizing, the speed of the traveling particles is higher
        case false:
            speed = 1;
           
            particle_mover(speed);
            break;
    }
    window.requestAnimationFrame(animate);
}
//function responsible for drawing all frames of the animation on the canvas
function responsible for drawing all frames of the animation on the canvas
function responsible for drawing all frames of the animation on the canvas
function animate() {
    ctx.globalCompositeOperation = 'destination-over';
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    ctx.strokeStyle = "black";
    ctx.save();
    canvas.width = win_width;
    canvas.height = win_height;
    if (particle_array.length < max_particle) {
        particle_generator(particle_array.length, max_particle);
    }
    switch (magnet_flag) {
        case true:
            var grav_constant = 2;
            ctx.beginPath();
            ctx.strokeStyle = "yellow";
            ctx.arc(mouse_x,mouse_y, 12, 0, Math.PI*2, true);
            ctx.closePath();
            ctx.stroke();
            speed = (1/500);
            particle_mover(speed);
            break;
        case false:
            speed = 1;
            particle_mover(speed);
            break;
    }
    window.requestAnimationFrame(animate);
}
function animate ( ) { ctx . globalCompositeOperation = 'destination-over' ; ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ; ctx . strokeStyle = "black" ; ctx . save ( ) ; canvas . width = win_width ; canvas . height = win_height ; if ( particle_array . length < max_particle ) { particle_generator ( particle_array . length , max_particle ) ; } switch ( magnet_flag ) { case true : var grav_constant = 2 ; ctx . beginPath ( ) ; ctx . strokeStyle = "yellow" ; ctx . arc ( mouse_x , mouse_y , 12 , 0 , Math . PI * 2 , true ) ; ctx . closePath ( ) ; ctx . stroke ( ) ; speed = ( 1 / 500 ) ; particle_mover ( speed ) ; break ; case false : speed = 1 ; particle_mover ( speed ) ; break ; } window . requestAnimationFrame ( animate ) ; }
function responsible for drawing all frames of the animation on the canvas
function responsible for drawing all frames of the animation on the canvas
//this if test is used to account for user changes in number of particles between animation frames //when the magnet flag is true, a yellow arc is drawn at the user position and the speed of particles traveling is lowered //when the user is not magnetizing, the speed of the traveling particles is higher