mercredi 11 mai 2016

drawing random line as a new position of a div is being made

I'm trying to draw a bunch of random line using four loops as my div is making new position moving around using (jquery). However, the code seems like it's not working

function makeNewPosition(){
   var h = $(window). height() - 50;
   var w = $(window). width() - 180;

   var nh = Math.floor(Math.random() * h);
   var nw = Math.floor(Math.random() * w);

   return [nh,nw];
}

var shuffle = function () {
  $('.message').each(function () {
    var newq = makeNewPosition();
    this.style.left = newq[1];
    this.style.top = newq[0];
  });
};

var x = Math.floor(Math.random() * 500);
var y = Math.floor(Math.random() * 500);
var createCricle = function (){
  if(Math.random() > nh) {
    for(var i = 0; i < limit; i += 1) {
      ctx.moveTo(x,y);
      ctx.lineTo(x,y);
      ctx.stroke();
      ;
    }  }

}




Aucun commentaire:

Enregistrer un commentaire