mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-25 06:36:49 +09:00
feat(ruflo-console): ASCII glitch in the page-title strike-in (ADR-433)
Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
1 parent
adbfb02ce8
commit
02bd83bfb0
3 files changed
+38
No files matched your search
@@ -284,6 +284,7 @@ const NEON_CORAL = 0xff7a59
|
||||
*/
|
||||
/** A page title strikes in over this long when the page is switched to. */
|
||||
export const TITLE_ENTRY_MS = 1_200
|
||||
const GLITCH = '#%&@/\\|<>=+*'
|
||||
|
||||
export function titlePicture(name: string, columns: number, t: number, age = Infinity): Grid {
|
||||
const grid = new Grid(columns, 2)
|
||||
@@ -331,6 +332,18 @@ export function titlePicture(name: string, columns: number, t: number, age = Inf
|
||||
|
||||
if (x > lead + 1) grid.set(x, y, '░▒▓█'[hash(x * 7 + y + Math.floor(age / 60)) % 4] as string, mix(0x3a0f2e, NEON_CYAN, 0.35))
|
||||
else if (x > lead - 1.5) grid.set(x, y, grid.glyph(x, y), 0xffffff)
|
||||
// Behind the edge the letters are settled but still glitching: some flip to an ASCII character for a frame, pink or cyan, less as the entry ends.
|
||||
else if (hash(x * 13 + y * 7 + Math.floor(age / 50)) % 100 < 14 * (1 - age / TITLE_ENTRY_MS)) grid.set(x, y, GLITCH[hash(x + y + Math.floor(age / 50)) % GLITCH.length] as string, hash(x + Math.floor(age / 50)) % 2 === 0 ? 0xff2a6d : 0x05d9e8)
|
||||
}
|
||||
|
||||
// And now and then a whole row slips sideways a cell or two, and snaps back.
|
||||
const slip = hash(y * 5 + Math.floor(age / 80))
|
||||
|
||||
if (slip % 6 === 0 && age < TITLE_ENTRY_MS - 150) {
|
||||
const by = 1 + (slip >>> 3) % 2 * (slip % 2 === 0 ? 1 : -1)
|
||||
const row = grid.cells.slice(y * columns * 3, (y + 1) * columns * 3)
|
||||
|
||||
for (let x = x0; x < Math.min(columns, x0 + width); x++) grid.cells.set(row.slice(Math.max(0, x - by) * 3, Math.max(0, x - by) * 3 + 3), (y * columns + x) * 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,3 +125,24 @@ describe('a page title when the page is switched to', () => {
|
||||
expect(cells(300)).toBe(cells(300))
|
||||
})
|
||||
})
|
||||
|
||||
describe('the title glitch', () => {
|
||||
it('puts ASCII glitch characters in the strike-in, in pink or cyan, and none once it is over', async () => {
|
||||
const { titlePicture, TITLE_ENTRY_MS } = await import('../hooks/gfx/pictures')
|
||||
const ascii = (age: number): number => {
|
||||
const grid = titlePicture('ruflo | Swarm', 80, 0, age)
|
||||
let n = 0
|
||||
|
||||
for (let i = 0; i < grid.cells.length; i += 3) if ('#%&@/\\|<>=+*'.includes(String.fromCodePoint(grid.cells[i] as number))) n++
|
||||
|
||||
return n
|
||||
}
|
||||
let early = 0
|
||||
|
||||
for (let age = 50; age < 700; age += 50) early += ascii(age)
|
||||
|
||||
expect(early).toBeGreaterThan(0)
|
||||
expect(ascii(TITLE_ENTRY_MS)).toBe(ascii(Infinity))
|
||||
expect(ascii(Infinity)).toBe(0)
|
||||
})
|
||||
})
|
||||
@@ -18,3 +18,7 @@ Extends: ADR 430 (the menu), ADR 432 (the boot uplink).
|
||||
## 2. Not proven
|
||||
|
||||
Seen only as text and element trees, not on a terminal. A press on an entry while it is still scrambling does nothing (it is not a button yet); the hotkeys are handled elsewhere and work.
|
||||
|
||||
## 3. Amendment: ASCII glitch in the strike-in
|
||||
|
||||
Behind the leading edge, a share of the settled letters (14%, fading to none by the end) flip for a frame to an ASCII character (`#%&@/\|<>=+*`) in pink or cyan, and a title row now and then slips sideways one or two cells and snaps back. Hash-driven, so reproducible; none once the 1.2 s are over (spec: glitch characters appear during the entry and the finished title has none).
|
||||
Reference in new issue
Block a user