UNPKG

@zsnout/ithkuil

Version:

A set of tools which can generate and parse romanized Ithkuil text and which can generate Ithkuil script from text and JSON data.

46 lines (45 loc) 1.96 kB
import { jsx as _jsx } from "@zsnout/ithkuil-jsx/jsx-runtime"; import { CharacterRow, HandleResult, Lines, fitViewBox, textToScript, } from "./index.js"; import { HANDWRITTEN_THOUSANDS, Numeral } from "./numerals/index.js"; document.body.append(_jsx("script", { children: `new EventSource("/esbuild").addEventListener("change", () => location.reload())` })); const lines___ = false; const HEIGHT__ = 150; const mode____ = false; const doFitBox = true; const t__________ = "transliterative"; const b_______ = "SPF"; function randomItem(x) { if (x.length == 0) { throw new Error(); } return x[Math.floor(Math.random() * x.length)]; } const output = textToScript("Q1welo Q2á Q3aoLe Q4hmei QIAei hi2 zac '", false); function getColor(index) { const colors = ["blue", "green", "red", "purple", "orange"]; return colors[~~index % colors.length]; } const value = (HANDWRITTEN_THOUSANDS.length - 1) * 1000 + 4; const numeral = (_jsx(Numeral, { value: value })); // debug("v:", value) // debug("w:", getBBox(numeral).width) // debug("h:", (getBBox(numeral).height - 70) / 2) const node = (_jsx("svg", { viewBox: { a: `${-HEIGHT__ * (innerWidth / innerHeight)} ${-HEIGHT__} ${2 * HEIGHT__ * (innerWidth / innerHeight)} ${2 * HEIGHT__}`, b: "-50 -50 100 100", c: "-50 -50 60 60", d: "10 -45 30 30", }.a, "background-color": "#f7f7f7", children: _jsx(HandleResult, { ok: (x) => _jsx(CharacterRow, { children: x }), error: (x) => _jsx("text", { children: x }), children: output }) })); // @ts-ignore node.style = "max-height:100vh;max-width:100vw;background:#f0f0f0"; // @ts-ignore document.body.style = "margin:0;display:flex;align-items:center;justify-content:center"; document.body.appendChild(node); if (doFitBox) { fitViewBox(node, typeof doFitBox == "number" ? doFitBox : 20); } if (lines___) { node.insertBefore(_jsx(Lines, { width: 500, height: 0 }), node.children[0] || null); }