27.12.09

Playful

//TODO: get code prettifier for blog :)

I feel like creating art with javascript.


<!doctype>
<style>
*{margin:0;padding:0;border:0}
body{
height:100%;
width:100%;
}
div{
background:red;
margin:auto;
}
</style>
<body>
<script>
console.log('ok', Phi = Math.sqrt(5)/2 + .5);

(function(step){
  console.log(step);

  plot(step);
  
  if (step > Phi) arguments.callee.call(this, step / Phi);
  else setTimeout(arguments.callee, step * Phi);

})();

/**
 * Example plot function
 * @param n The step number from balancer function
 */
function plot(n){
  // font size allows for a one-time value change in the page that will affect
  // relatively-defined units, in this case divs with em dimensions.
  var last = parseInt(document.body.style.fontSize)/100 || 0;
  n = n || last;
  // Pick relatively larger number
  // This number is a relative maximum
  var max = Math.sqrt(last || 1 * n) * 100;
  document.body.style.fontSize = max + '%';
  
  // relative rendering number
  var rel = n/max;
  
  var block = document.createElement('div');
  
  block.style.backgroundColor = 'red';
  
  block.style.MozOpacity = n/100;
  block.style.height = '1em';
  block.style.width = rel * 50 + '%';
  document.body.appendChild(block);
  if (window.scrollMaxY) document.body.removeChild(document.body.firstChild);
  if (n < 0) document.body.innerHTML = '';
}
</script>
</body>

1 comment:

FB-E said...

Broad band is even broader, scripts are more efficient, machines are getting faster, and For what?!

98% of internet traffic is bull crapè anyway.

Books begat magazines, newsletters, briefs (the pieces of paper with relevant info), one-page-memoranda, telexes, facsimiles, E-Mails, blogs, SMS, tweets, What's next in the shrinking of messages? No data, just ads?