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.

66 lines (65 loc) 2.05 kB
import { jsx as _jsx } from "@zsnout/ithkuil-jsx/jsx-runtime"; import { deepFreezeAndNullPrototype, } from "../../generate/index.js"; import { Diacritic } from "../other/diacritic.js"; import { Anchor } from "../utilities/anchor.js"; /** * An object mapping from affiliation and essence to their corresponding * diacritics. */ export const AFFILIATION_ESSENCE_DIACRITICS = /* @__PURE__ */ deepFreezeAndNullPrototype({ NRM: { CSL: "", ASO: "DIAG_BAR", VAR: "VERT_BAR", COA: "HORIZ_BAR", }, RPV: { CSL: "HORIZ_WITH_BOTTOM_LINE", ASO: "VERT_WITH_LEFT_LINE", VAR: "CURVE_TO_TOP", COA: "CURVE_TO_BOTTOM", }, }); const OFFSETS = /* @__PURE__ */ deepFreezeAndNullPrototype({ NRM: { CSL: { x: 0, y: 0 }, ASO: { x: 0, y: 0 }, VAR: { x: 0, y: -17.5 }, COA: { x: 7.5, y: 0 }, }, RPV: { CSL: { x: 7.5, y: 0 }, ASO: { x: 0, y: -17.5 }, VAR: { x: 7.5, y: 0 }, COA: { x: 7.5, y: 0 }, }, }); const HANDWRITTEN_OFFSETS = /* @__PURE__ */ deepFreezeAndNullPrototype({ NRM: { CSL: { x: 0, y: 0 }, ASO: { x: 0, y: 0 }, VAR: { x: 0, y: 0 }, COA: { x: 0, y: 0 }, }, RPV: { CSL: { x: 0, y: 0 }, ASO: { x: 0, y: 0 }, VAR: { x: 0, y: 0 }, COA: { x: 0, y: 0 }, }, }); /** * Creates the top-right diacritic of a primary character as an SVG path. * * @param props Properties that modify the diacritic. * @returns An `SVGPathElement` containing the diacritic, or `undefined` if no * diacritic is needed. */ export function PrimaryTopRight({ handwritten, affiliation = "CSL", essence = "NRM", }) { const diacriticName = AFFILIATION_ESSENCE_DIACRITICS[essence][affiliation]; if (!diacriticName) { return undefined; } return (_jsx(Anchor, { at: "tr", ...(handwritten ? HANDWRITTEN_OFFSETS : OFFSETS)[essence][affiliation], children: _jsx(Diacritic, { handwritten: handwritten, name: diacriticName }) })); }