Gracias, Wikipedia.
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 <script type="text/javascript">2 3 function r(m) {4  return (m*Math.random()).toFixed(0);5 };6 7 var Box = function(dom) {8  this.dom = dom;9  this.dom.setAttribute('data-component', 'box');10 };11 12 Box.prototype.start = function() {13  14  var h = r(200);15  var w = r(200);16 17  this.dom.style.width = h + 'px';18  this.dom.style.height = w + 'px';19 20  this.dom.style.left = r(1920-w) + 'px';21  this.dom.style.top = r(1080-h) + 'px';22  23  this.dom.style.backgroundColor = 'rgba('+128*r(2)+','+128*r(2)+','+128*r(2)+', '+(r(10)/10)+')';24 25  var that = this;26  setTimeout(function() {27  that.start(); 28  }, r(1000));29 };30 31 var boxes = document.querySelectorAll('[data-component="box"]');32 33 for (var i=0; i<boxes.length; i++) {34  var box = new Box(boxes[i]);35  box.start();36 }37 38 for (var i=0; i<50; i++) {39  var div = document.createElement('div');40  document.body.appendChild(div);41  var box = new Box(div);42  box.start();43 }44 45 46 47 </script>


Este ShareCode tiene versiones:
  1. function r(m) { return (m*Math.ran... (17/04/2015)
  2. function r(m) { return (m*Math.ran... (18/09/2021)
Enlace
El enlace para compartir es:

Powered by TreeWeb
© TreeWeb 2010. Todos los derechos reservados