title: Apply Gradient to Canvas and moving balls
body: <p>Trying to apply a linear gradient to my canvas and it's moving balls but I don't know where I went wrong as nothing changes. I'm trying to have a randomly colored and random angle applied onload every time. I think the problem is in my onload function when I create the linear gradient</p>
  
  <pre><code>var $ = function(id) {return document.getElementById(id);};
  
  var bounce;
  var my_canvas;
  var ball_array = new Array();
  var linear_gradient;
  var timer; //global variable to keep current timer
  
  function randomGradient()
  {
  var color1 = randomColor(); //color 1
  var color2 = '#FFFFFF'; //color 2
  var gradient_angle = Math.round(Math.random()*360);
  var random_gradient = "linear-gradient(" + gradient_angle + "deg, " + color1 + ", " + color2 + ")";
  return random_gradient;
  }
  
  function ball(){
  this.x=Math.random()*my_canvas.canvas.width;
  this.y=Math.random()*my_canvas.canvas.height;
  this.vx = (Math.random()-0.5);
  this.vy = (Math.random()-0.5);
   this.color = randomGradient();
   this.radius = 12;
  this.move=ball_move;
  this.draw=ball_draw;
   }
   function ball_draw(){                    
   my_canvas.save();
   my_canvas.fillStyle=this.color; //****
   my_canvas.strokeStyle='black';
   my_canvas.lineWidth=2;
   my_canvas.beginPath();
  my_canvas.arc(this.x, this.y, this.radius,0, 6.28, false);
   my_canvas.closePath();
   my_canvas.stroke();
   my_canvas.fill();
   my_canvas.restore();
   }
  
   function create_balls(){
   for(var i=0;i&lt;75;i++){
      var temp=new ball();
      ball_array.push(temp);
   }
   }
      function resize_can(){
  my_canvas.canvas.width = window.innerWidth/2;
  my_canvas.canvas.height = window.innerHeight/2;
      }
  
      window.onload = function() {
      bounce = -1;
      my_canvas = $("myCanvas").getContext('2d');
      linear_gradient = my_canvas.createLinearGradient(0,0,window.innerWidth / 2,window.innerHeight / 2); //create linear gradient
      window.onresize = resize_can;
      resize_can(); 
      create_balls();
      timer = setInterval(going,5);
    };
  </code></pre>