Creo en nosotros. Wikipedia.
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 var h = [2  [0,1,0,1,0],3  [1,1,1,1,1],4  [0,1,0,1,0],5  [1,1,1,1,1],6  [0,1,0,1,0],7 ];8 9 function colorize(bitmap) {10  var max_value = bitmap.length*bitmap.length;11  12  for (var y in bitmap) {13  var row = bitmap[y];14  for (var x in row) {15  var value = row[x];16  if (value != 0) {17  bitmap[x][y] = (1+parseInt(y))*(1+parseInt(x))/max_value;18  }19  }20  console.log(y);21  }22  23  return bitmap;24 }25 26 function expand(bitmap, n) {27  result = [];28  for (var y in bitmap) {29  var new_row = [];30  var row = bitmap[y];31  for (var x in row) {32  var value = row[x];33  for (var i=0; i<n; i++) {34  new_row.push(value);35  }36  }37  for (var i=0; i<n; i++) {38  result.push(new_row);39  }40  }41  return result;42 }43 44 function paint_bitmap(bitmap) {45  var result = '<div class="bitmap">';46  47  for (var y in bitmap) {48  result += '<div class="row">';49  var row = bitmap[y];50  for (var x in row) {51  var value = row[x];52  if (value != 0) {53  result += '<div class="cell" style="background-color: rgba(120, 150, 240,'+value+'")></div>';54  } else {55  result += '<div class="cell"></div>';56  }57  }58  result += '</div>';59  }60  61  result += '</div>';62  return result;63 }64 65 
Enlace
El enlace para compartir es: