1. Cat's Eye Technologies
  2. Gemooy

Commits

catseye  committed e60a1bb

Dist. org. guidelines: showing how gemooy.js can be used -> demo.

  • Participants
  • Parent commits c3b8761
  • Branches default

Comments (0)

Files changed (3)

File demo/gemooy.html

View file
+<!DOCTYPE html>
+<head>
+  <meta charset="utf-8">
+  <title>Gemooy</title>
+  <script src="../src/playfield.js"></script>
+  <script src="../src/gemooy.js"></script>
+  <style>
+#canvas { border: 1px solid blue; }
+#canvas_viewport {
+    width: 420px; height: 420px; overflow: scroll; border: 1px solid black;
+    display: inline-block;
+}
+#info { float: right; }
+  </style>
+</head>
+<body>
+
+<p id="info">
+Gemooy on:
+<a href="http://catseye.tc/node/Gemooy.html">catseye.tc</a> |
+<a href="https://github.com/catseye/Gemooy">github</a> |
+<a href="http://esolangs.org/wiki/Gemooy">esolangs wiki</a>
+</p>
+
+<h1>Gemooy
+<button id="load">Load</button>
+<button id="start">Start</button>
+<button id="stop">Stop</button>
+</h1>
+
+<div id="canvas_viewport">
+  <canvas id="canvas" width="400" height="400">
+    Your browser doesn't support displaying an HTML5 canvas.
+  </canvas>
+</div>
+
+<textarea id="program" rows="25" cols="40">
+%   @@   @@
+#  @  $    @
+       @
+#      #
+#
+       @
+#     # #
+#    #
+    @     @
+    @     @@
+#  @ @    @
+@   @   @
+</textarea>
+
+</body>
+<script>
+var eso = new GemooyController(document.getElementById('canvas'));
+document.getElementById('load').onclick = function() {
+    eso.load(document.getElementById('program'));
+};
+document.getElementById('start').onclick = function() {
+    eso.start();
+};
+document.getElementById('stop').onclick = function() {
+    eso.stop();
+};
+</script>

File html/gemooy.html

-<!DOCTYPE html>
-<head>
-  <meta charset="utf-8">
-  <title>Gemooy</title>
-  <script src="../src/playfield.js"></script>
-  <script src="../src/gemooy.js"></script>
-  <style>
-#canvas { border: 1px solid blue; }
-#canvas_viewport {
-    width: 420px; height: 420px; overflow: scroll; border: 1px solid black;
-    display: inline-block;
-}
-#info { float: right; }
-  </style>
-</head>
-<body>
-
-<p id="info">
-Gemooy on:
-<a href="http://catseye.tc/node/Gemooy.html">catseye.tc</a> |
-<a href="https://github.com/catseye/Gemooy">github</a> |
-<a href="http://esolangs.org/wiki/Gemooy">esolangs wiki</a>
-</p>
-
-<h1>Gemooy
-<button id="load">Load</button>
-<button id="start">Start</button>
-<button id="stop">Stop</button>
-</h1>
-
-<div id="canvas_viewport">
-  <canvas id="canvas" width="400" height="400">
-    Your browser doesn't support displaying an HTML5 canvas.
-  </canvas>
-</div>
-
-<textarea id="program" rows="25" cols="40">
-%   @@   @@
-#  @  $    @
-       @
-#      #
-#
-       @
-#     # #
-#    #
-    @     @
-    @     @@
-#  @ @    @
-@   @   @
-</textarea>
-
-</body>
-<script>
-var eso = new GemooyController(document.getElementById('canvas'));
-document.getElementById('load').onclick = function() {
-    eso.load(document.getElementById('program'));
-};
-document.getElementById('start').onclick = function() {
-    eso.start();
-};
-document.getElementById('stop').onclick = function() {
-    eso.stop();
-};
-</script>

File src/gemooy.js

View file
     var ip = new yoob.Cursor(0, 0, 1, 1);
     var dp = new yoob.Cursor(0, 0, 0, 0);
 
-    var c_width = canvas.width;
-    var c_height = canvas.height;
-
     this.draw = function() {
         var ctx = canvas.getContext('2d');
 
         ctx.font = height + "px monospace";
         var width = ctx.measureText("@").width;
 
-        var sym_width = (p.max_x - p.min_x + 1) * width;
-        var sym_height = (p.max_y - p.min_y + 1) * height;
-
-        canvas.width = sym_width;
-        canvas.height = sym_height;
+        canvas.width = (p.max_x - p.min_x + 1) * width;
+        canvas.height = (p.max_y - p.min_y + 1) * height;
 
         ctx.clearRect(0, 0, canvas.width, canvas.height);
         ctx.textBaseline = "top";