From 71ea63b48e019e5370e08e81efa16bb4cc984ee0 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sat, 7 Mar 2026 18:03:36 +0900 Subject: [PATCH] calculators update --- Autokem/apply.c | 2 +- README.md | 4 +-- keming_calculator.html | 79 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 75 insertions(+), 10 deletions(-) diff --git a/Autokem/apply.c b/Autokem/apply.c index 314760d..43455f1 100644 --- a/Autokem/apply.c +++ b/Autokem/apply.c @@ -135,7 +135,7 @@ int apply_model(const char *tga_path) { int lowheight = output[11] >= 0.5f; /* Compose Y+5 pixel: lowheight (alpha=0xFF when set) */ - uint32_t lh_pixel = lowheight ? 0x000000FF : 0x00000000; + uint32_t lh_pixel = lowheight ? 0xFFFFFFFF : 0x00000000; tga_write_pixel(tga_path, img, tag_x, tag_y + 5, lh_pixel); /* Compose Y+6 pixel: diff --git a/README.md b/README.md index 704a4d9..1822a59 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Font sample — necessary information in this image is also provided below.](demo.PNG) -This font is a bitmap font used in [my game project called Terrarum](https://github.com/curiuostorvald/Terrarum) (hence the name). The font supports more than 90 % of european languages, as well as Chinese, Japanese, and Korean. +This font is a bitmap font used in [my game project called Terrarum](https://github.com/curioustorvald/Terrarum) (hence the name). The font supports more than 90 % of european languages, as well as Chinese, Japanese, and Korean. The font is provided in following formats: @@ -27,7 +27,7 @@ The issue page is open. If you have some issues to submit, or have a question, p ## Download -- Go ahead to the [release tab](https://github.com/curiuostorvald/Terrarum-sans-bitmap/releases), and download the most recent version. It is **not** advised to use the .jar found within the repository, they're experimental builds I use during the development, and may contain bugs like leaking memory. +- Go ahead to the [release tab](https://github.com/curioustorvald/Terrarum-sans-bitmap/releases), and download the most recent version. It is **not** advised to use the .jar found within the repository, they're experimental builds I use during the development, and may contain bugs like leaking memory. ## Using on your LibGDX project diff --git a/keming_calculator.html b/keming_calculator.html index bd7e10b..f637ad9 100644 --- a/keming_calculator.html +++ b/keming_calculator.html @@ -98,10 +98,10 @@ h1 { font-size: 1.4em; margin-bottom: 4px; color: #111; } .pixel-inactive { font-size: 0.85em; color: #999; } .bit-display { font-family: 'Consolas', 'Fira Code', monospace; font-size: 0.8em; color: #777; margin-top: 2px; } -/* Mask display */ +/* Mask input/display */ .mask-section { margin-top: 16px; padding: 10px; background: #f8f8f8; border-radius: 6px; border: 1px solid #e0e0e0; } .mask-section .label { font-size: 0.8em; color: #1a5fb4; margin-bottom: 4px; } -.mask-val { font-family: 'Consolas', 'Fira Code', monospace; font-size: 0.95em; color: #111; } +.mask-input-row { display: flex; gap: 8px; align-items: center; } /* Examples */ .examples-section { margin-top: 20px; } @@ -207,11 +207,16 @@ h1 { font-size: 1.4em; margin-bottom: 4px; color: #111; }

- +
-
Kerning Mask (24-bit, used by rules)
-
0x0000FF
-
00000000 00000000 11111111
+
Kerning Mask (24-bit hex colour)
+
+ +
+

+ Accepts: #RRGGBB, 0xRRGGBB, or RRGGBB +

+
00000000 00000000 00000000
@@ -290,6 +295,7 @@ h1 { font-size: 1.4em; margin-bottom: 4px; color: #111; } const ZONES = ['A','B','C','D','E','F','G','H','J','K']; const state = { A:0, B:0, C:0, D:0, E:0, F:0, G:0, H:0, J:0, K:0 }; let isLowheight = false; +let maskInputActive = false; // prevent recalc from overwriting mask input while user types // Bit positions within kerning_mask (24-bit RGB): // Blue byte: A=bit7, B=bit6, C=bit5, D=bit4, E=bit3, F=bit2, G=bit1, H=bit0 @@ -360,12 +366,71 @@ function recalc() { document.getElementById('b2').textContent = b; document.getElementById('bits2').textContent = bin8(r) + ' ' + bin8(g) + ' ' + bin8(b); - document.getElementById('maskVal').textContent = '0x' + fullMask.toString(16).toUpperCase().padStart(6, '0'); + // Update mask input only if the change didn't come from the mask input itself + if (!maskInputActive) { + document.getElementById('maskInput').value = '#' + hex2(r) + hex2(g) + hex2(b); + document.getElementById('maskInput').classList.remove('error'); + } document.getElementById('maskBin').textContent = bin8((fullMask >> 16) & 0xFF) + ' ' + bin8((fullMask >> 8) & 0xFF) + ' ' + bin8(fullMask & 0xFF); drawSwatchSolid('swatch2', r, g, b); } +function updateFromMask() { + const input = document.getElementById('maskInput'); + const raw = input.value.trim(); + + if (raw === '') { + input.classList.remove('error'); + return; + } + + // Parse hex colour: #RRGGBB, 0xRRGGBB, or RRGGBB + let hex = null; + if (/^#([0-9A-Fa-f]{6})$/.test(raw)) { + hex = parseInt(RegExp.$1, 16); + } else if (/^0[xX]([0-9A-Fa-f]{6})$/.test(raw)) { + hex = parseInt(RegExp.$1, 16); + } else if (/^([0-9A-Fa-f]{6})$/.test(raw)) { + hex = parseInt(RegExp.$1, 16); + } + + if (hex === null) { + input.classList.add('error'); + return; + } + input.classList.remove('error'); + + const r = (hex >> 16) & 0xFF; + const g = (hex >> 8) & 0xFF; + const b = hex & 0xFF; + + // Reverse-map to zone states + state.A = (b & 0x80) ? 1 : 0; + state.B = (b & 0x40) ? 1 : 0; + state.C = (b & 0x20) ? 1 : 0; + state.D = (b & 0x10) ? 1 : 0; + state.E = (b & 0x08) ? 1 : 0; + state.F = (b & 0x04) ? 1 : 0; + state.G = (b & 0x02) ? 1 : 0; + state.H = (b & 0x01) ? 1 : 0; + state.J = (g & 0x80) ? 1 : 0; + state.K = (g & 0x40) ? 1 : 0; + + // Reverse-map Y toggle + document.getElementById('yToggle').checked = !!(r & 0x80); + + // Update all zone buttons + document.querySelectorAll('.zone-btn').forEach(btn => { + btn.classList.toggle('active', !!state[btn.dataset.zone]); + }); + + // Recalc without overwriting the mask input + maskInputActive = true; + recalc(); + maskInputActive = false; +} + function updateCodepoint() { const input = document.getElementById('cpInput'); const raw = input.value.trim();