Digits Bitmap

by Daniel Cheung

HTML

<pre id="o"><code></code></pre>

JavaScript

let numbers = [
	[0b000000000, 0b0000000000, 0b0000000000, 0b0000000000, 0b0000000000, 0b0000000000, 0b0000000000],
  [0b000000000, 0b0010100000, 0b1110101101, 0b1111101111, 0b1111111101, 0b0010100000, 0b0000000000],
  [0b000000000, 0b1100101101, 0b0001000010, 0b0000010010, 0b0000010000, 0b1110001101, 0b0000000000],
  [0b000000000, 0b1101100001, 0b0000110000, 0b0000100010, 0b0010110001, 0b1100001101, 0b0000000000],
  [0b000000000, 0b0001000001, 0b1101010000, 0b1101001011, 0b1111011100, 0b1000100001, 0b0000000000],
  [0b000000000, 0b0101010001, 0b0000000001, 0b0010000110, 0b0000010000, 0b1101101001, 0b0000000000],
  [0b000000000, 0b0101111001, 0b0000010100, 0b0010010010, 0b1000010000, 0b0101111001, 0b0000000000],
  [0b000000000, 0b0000000100, 0b1101101111, 0b1111101111, 0b0101111111, 0b0000000100, 0b0000000000],
  [0b000000000, 0b0000000000, 0b0000000000, 0b0000000000, 0b0000000000, 0b0000000000, 0b0000000000]
];
let outlines = [];
let outlinesBinary = [];
let masks = [1,2,4,8,16,32,64,128,256,512];

let directions = [
	[-1, -1], [0, -1], [1, -1],
	[-1,  0],          [1,  0],
	[-1,  1], [0,  1], [1,  1]
];

let o = document.getElementById("o");

for (let i = 0; i < 10; i++) {
  let outlineRows = [];
	numbers.forEach(row => {
    let outlineCols = [];
    row.forEach(col => outlineCols.push(0));
    outlineRows.push(outlineCols);
  });
  outlines = outlineRows;
}


for (let i = 0; i < 10; i++) {
	numbers.forEach((row, y) => {
    row.forEach((col, x) => {
      let hasPixel = (col & masks[i]) >> i == 1;
      if (hasPixel) {
        exploreAndDarken(i, x, y);
      }
      o.innerHTML += hasPixel ? "M" : " ";
    });
    o.innerHTML += "\n";
  });
  o.innerHTML += "\n";
  
  let binaryRows = [];
	outlines.forEach((row, y) => {
    let binaryCols = [];
    row.forEach((col, x) => {
      row[x] ^= numbers[y][x];
      binaryCols.push("0b" + row[x].toString(2));
      let has_pixel = (row[x] & masks[i]) >> i == 1;
      o.innerHTML += has_pixel ? "M" : " ";
    });
 ...