No al cierre de webs
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 var h = [2  [0,1,1,1,1, 1,1,1,1,1, 0, 0,1,1,1,0, 0, 1,1,1,1,0, 0, 1,0,0,0,1, 0, ],3  [1,0,0,0,0, 0,0,1,0,0, 0, 1,0,0,0,1, 0, 1,0,0,0,1, 0, 1,1,0,1,1, 0, ],4  [0,1,1,1,0, 0,0,1,0,0, 0, 1,0,0,0,1, 0, 1,1,1,1,0, 0, 1,0,1,0,1, 0, ],5  [0,0,0,0,1, 0,0,1,0,0, 0, 1,0,0,0,1, 0, 1,0,0,0,1, 0, 1,0,0,0,1, 0, ],6  [1,1,1,1,0, 0,0,1,0,0, 0, 0,1,1,1,0, 0, 1,0,0,0,1, 0, 1,0,0,0,1, 0, ],7  8  [0],9  10  [0,0, 1,1,1,1,1, 0, 1,1,1,1,1, 0, 0,1,1,1,0, 0, 1,0,0,0,1],11  [0,0, 0,0,1,0,0, 0, 1,0,0,0,0, 0, 1,0,0,0,1, 0, 1,1,0,1,1],12  [0,0, 0,0,1,0,0, 0, 1,1,1,1,0, 0, 1,1,1,1,1, 0, 1,0,1,0,1],13  [0,0, 0,0,1,0,0, 0, 1,0,0,0,0, 0, 1,0,0,0,1, 0, 1,0,0,0,1],14  [0,0, 0,0,1,0,0, 0, 1,1,1,1,1, 0, 1,0,0,0,1, 0, 1,0,0,0,1],15 ];16 17 function clone(data) {18  return JSON.parse(JSON.stringify(data));19 };20 21 function colorize(bitmap, randomness) {22  var max_value = bitmap.length*bitmap[0].length;23  24  for (var y in bitmap) {25  var row = bitmap[y];26  for (var x in row) {27  var value = row[x];28  if (value != 0) {29  var rx = 1+parseInt(x) - randomness + Math.floor(Math.random()*randomness*2);30  var ry = 1+parseInt(y) - randomness + Math.floor(Math.random()*randomness*2);31  bitmap[y][x] = 1 - rx*ry/max_value;32  }33  }34  }35  36  return bitmap;37 }38 39 function expand(bitmap, n) {40  result = [];41  for (var y in bitmap) {42  var new_row = [];43  var row = bitmap[y];44  for (var x in row) {45  var value = row[x];46  for (var i=0; i<n; i++) {47  new_row.push(value);48  }49  }50  for (var i=0; i<n; i++) {51  result.push(clone(new_row));52  }53  }54  return result;55 }56 57 function paint_bitmap(bitmap) {58  var result = '<div class="bitmap">';59  60  for (var y in bitmap) {61  result += '<div class="row">';62  var row = bitmap[y];63  for (var x in row) {64  var value = row[x];65  if (value != 0) {66  result += '<div class="cell" style="background-color: rgba(220, 050, 140,'+value+'")></div>';67  } else {68  result += '<div class="cell"></div>';69  }70  }71  result += '</div>';72  }73  74  result += '</div>';75  return result;76 }77 78 


Este ShareCode tiene versiones:
  1. Expand factor Randomness Animat... (18/04/2015)
  2. Expand factor Randomness Animat... (18/09/2021)
Enlace
El enlace para compartir es: