git @ Cat's Eye Technologies yoob.js / rel_0_4 eg / tape.html
rel_0_4

Tree @rel_0_4 (Download .tar.gz)

tape.html @rel_0_4raw · history · blame

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <title>yoob.Tape Demo</title>
  <script src="../src/yoob/tape.js"></script>
  <script src="../src/yoob/tape-head.js"></script>
  <style>
#canvas { border: 1px solid blue; }
  </style>
</head>
<body>

<h1>yoob.Tape Demo</h1>

<canvas id="canvas" width="400" height="40">
Your browser doesn't support displaying an HTML5 canvas.
</canvas>

<button id="write_0">Write 0</button>
<button id="write_1">Write 1</button>
<button id="left">Move Left</button>
<button id="right">Move Right</button>

</body>
<script>
  var canvas = document.getElementById('canvas');
  var tape = new yoob.Tape();
  var th = new yoob.TapeHead(tape, 0);

  document.getElementById('write_0').onclick = function(e) {
    th.write("0");
    tape.drawCanvas(canvas, undefined, 20, [th]);
  };

  document.getElementById('write_1').onclick = function(e) {
    th.write("1");
    tape.drawCanvas(canvas, undefined, 20, [th]);
  };

  document.getElementById('left').onclick = function(e) {
    th.moveLeft();
    tape.drawCanvas(canvas, undefined, 20, [th]);
  };

  document.getElementById('right').onclick = function(e) {
    th.moveRight();
    tape.drawCanvas(canvas, undefined, 20, [th]);
  };

</script>