Skip to content

Instantly share code, notes, and snippets.

@vinaydotblog
Created October 1, 2016 22:49
Show Gist options
  • Select an option

  • Save vinaydotblog/35c40afe27dc5620ff6cf52b5bd60b35 to your computer and use it in GitHub Desktop.

Select an option

Save vinaydotblog/35c40afe27dc5620ff6cf52b5bd60b35 to your computer and use it in GitHub Desktop.

Revisions

  1. Vinay Aggarwal created this gist Oct 1, 2016.
    27 changes: 27 additions & 0 deletions digits2image.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@

    <canvas id="can" width="800" height="800"></canvas>
    <script>
    var lol = [0.0, 0.0, 0.0, 0.0, 11.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 15.0, 14.0, 0.0, 0.0, 0.0, 0.0, 0.0, 11.0, 16.0, 11.0, 0.0, 0.0, 0.0, 0.0, 9.0, 16.0, 16.0, 10.0, 0.0, 0.0, 0.0, 4.0, 16.0, 12.0, 16.0, 12.0, 0.0, 0.0, 0.0, 3.0, 10.0, 3.0, 16.0, 11.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 16.0, 14.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 11.0, 11.0, 0.0, 0.0];
    var img = [];

    while( lol.length ){ img.push( lol.splice(0,8) ) }

    var can = document.querySelector('#can');

    var ctx = can.getContext('2d');
    var base = 10;
    var base2 = 10;

    img.forEach(function(line, i){

    line.forEach(function(dot, j){
    if(dot){
    ctx.globalAlpha = j / 16;
    ctx.fillRect(i * base,j * base2, base, base2);
    }
    });

    });

    </script>