News for hackers. Stuff that matters.
Re:C64 Keyboard Prototype by sp332 on Thursday May 03, 2018 @03:48PM (#16989234)
You can save this as an HTML file:

  <canvas id="canvas" width="400" height="400"></canvas>

  <script>
  var canvas = document.getElementById('canvas');
  var ctx = canvas.getContext('2d');
  var width = canvas.width;
  var height = canvas.height;
  var imagedata = ctx.createImageData(width, height);

  function draw(r, g, b, x, y){
    var pixelindex = (y * width + x) * 4;
    imagedata.data[pixelindex] = r;
    imagedata.data[pixelindex+1] = g;
    imagedata.data[pixelindex+2] = b;
    imagedata.data[pixelindex+3] = 255; //alpha
    ctx.putImageData(imagedata, 0, 0);
  }

  </script>
This gives you a 400x400 space to draw on. Open the console and call draw().

  draw(0,0,0,15,15);

There are no comments on this comment yet.