chiark / gitweb /
webstead: generate initialisers to paste into bedstead.c
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 20 Sep 2025 20:44:19 +0000 (21:44 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 13 Jan 2026 21:42:18 +0000 (21:42 +0000)
webstead.xhtml

index 39e07a69d5bb4025b8088dc1616a57571c8c9d1b..f2bdd1cdce554aa0f811e91c453d8e1b6458338f 100644 (file)
@@ -40,6 +40,7 @@
     import Bedstead from './bedstead.js';
     function update_glyph() {
         var args = [];
+        var cstr = "";
         for (var row of document.getElementById("pixels").rows) {
             var arg = 0;
             for (var pixel of row.getElementsByTagName('input')) {
                     arg += 1
                 }
             }
-            args.push(arg.toString())
+            args.push(arg.toString());
+            cstr += "\\" + arg.toString(8).padStart(2, "0");
         }
+        document.getElementById("c").textContent =
+            ` {"${cstr}", U() },`;
         Bedstead({
             arguments: args,
             print: function(charstring) {
-                document.getElementById("output").textContent = charstring;
+                document.getElementById("charstring").textContent = charstring;
                 document.getElementById("rendered")
                     .setAttribute("d", charstring
                                   .replaceAll(/<!--(?:[^-]|-[^-])*-->/g, "")
@@ -68,6 +72,7 @@
     for (var e of document.getElementsByTagName('input')) {
         e.onchange = update_glyph;
     }
+    update_glyph();
 ]]>
     </script>
   </head>
         </svg>
       </div>
     </div>
-    <p><code id="output"></code></p>
+    <p><code id="c"></code></p>
+    <p><code id="charstring"></code></p>
   </body>
 </html>