Skip to content
blackopsreplPublic

About

Pure-C17 parity port of ttfx: terminal text effects

Resources

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

glyphfx

The GlyphFX Cursor Gecko mascot, with terminal glyphs resolving along its C-shaped tail

Terminal text effects as a single C17 binary. Pipe text in, pick an effect:

ls -la | glyphfx decrypt
cat banner.txt | glyphfx beams
fortune | glyphfx --random-effect
git log --oneline -10 | glyphfx matrix

the wipe effect resolving the glyphfx banner

Why C

The effects are a shell toy that lives in a prompt pipeline, so startup and throughput matter. glyphfx links nothing but libc and libm — no interpreter, no import step, no third-party libraries — and starts in well under a millisecond.

The tempting alternative is hand-written assembly. ttfx tried it: an x86-64 engine landed in omacom/ttfx#35 and was removed again in 7444eea, which states that ttfx's portable Rust engine (fx) matches or beats it on every effect; in the matrix below fx is faster on 36 of the 37 effects and asm on the other one. fx is the fastest port that ships, and glyphfx draws the same conclusion:

  • The gains are algorithmic, not instruction-level. fx credits structure-of-arrays character storage, interned visuals, an incremental cell grid, skipped idle ticks and batched writes for its speed — all expressible in C. fx is glyphfx's performance target, chased by transcribing that design into portable C rather than re-deriving it.
  • Assembly ties the fast path to one ISA. The ttfx assembly engine needed NASM and per-tier x86-64 builds; everywhere else it declined and ran the old code. Portable C is the same program on every CPU.
  • A byte-exact target makes a second implementation a liability. Every effect must reproduce ttfx bit for bit, including banker's rounding and libm results; a hand-tuned assembly engine doubles the surface where the two can silently diverge.

Why not assembly? There is no frame budget to win. glyphfx paces itself at 60 fps and hands one batched frame to the terminal per tick; the thousands-of-fps figures are a benchmark, not the product. Data layout and skipped work are what make the benchmark faster, and that is portable C work.

The result builds anywhere with a C compiler, starts in about 0.3 ms, and renders every effect at thousands to tens of thousands of frames per second with pacing disabled.

The effects

All 37, each with a full option surface (glyphfx <effect> --help).

beams
beams
Create beams which travel over the canvas illuminating the characters behind them.
binarypath
binarypath
Binary representations of each character move towards the home coordinate of the character.
blackhole
blackhole
Characters are consumed by a black hole and explode outwards.
bouncyballs
bouncyballs
Characters are bouncy balls falling from the top of the canvas.
bubbles
bubbles
Characters are formed into bubbles that float down and pop.
burn
burn
Burns vertically in the canvas.
colorshift
colorshift
Display a gradient that shifts colors across the terminal.
crumble
crumble
Characters lose color and crumble into dust, vacuumed up, and reformed.
decrypt
decrypt
Display a movie style decryption effect.
errorcorrect
errorcorrect
Some characters start in the wrong position and are corrected in sequence.
expand
expand
Expands the text from a single point.
fireworks
fireworks
Characters launch and explode like fireworks and fall into place.
highlight
highlight
Run a specular highlight across the text.
laseretch
laseretch
A laser etches characters onto the terminal.
matrix
matrix
Matrix digital rain effect.
middleout
middleout
Text expands in a single row or column in the middle of the canvas then out.
orbittingvolley
orbittingvolley
Four launchers orbit the canvas firing volleys of characters inward to build the input text from the center out.
overflow
overflow
Input text overflows and scrolls the terminal in a random order until eventually appearing ordered.
pour
pour
Pours the characters into position from the given direction.
print
print
Lines are printed one at a time following a print head. Print head performs line feed, carriage return.
rain
rain
Rain characters from the top of the canvas.
randomsequence
randomsequence
Prints the input data in a random sequence.
rings
rings
Characters are dispersed and form into spinning rings.
scattered
scattered
Text is scattered across the canvas and moves into position.
slice
slice
Slices the input in half and slides it into place from opposite directions.
slide
slide
Slide characters into view from outside the terminal.
smoke
smoke
Smoke floods the canvas colorizing any characters it crosses.
spotlights
spotlights
Spotlights search the text area, illuminating characters, before converging in the center and expanding.
spray
spray
Draws the characters spawning at varying rates from a single point.
swarm
swarm
Characters are grouped into swarms and move around the terminal before settling into position.
sweep
sweep
Sweep across the canvas to reveal uncolored text, reverse sweep to color the text.
synthgrid
synthgrid
Create a grid which fills with characters dissolving into the final text.
thunderstorm
thunderstorm
Create a thunderstorm in the terminal.
unstable
unstable
Spawn characters jumbled, explode them to the edge of the canvas, then reassemble them in the correct layout.
vhstape
vhstape
Lines of characters glitch left and right and lose detail like an old VHS tape.
waves
waves
Waves travel across the terminal leaving behind the characters.
wipe
wipe
Wipes the text across the terminal to reveal characters.

glyphfx originals

Six effects that ttfx does not have: four from the SolverForge demoscene productions, and rotozoom and stack, written for glyphfx in the same spirit. They follow the same contract (text in, the text in place at the end; burnout is the one exit effect) but sit outside byte parity: --random-effect draws them only when they are named in --include-effects, and make originals holds them to determinism, golden streams and a final-frame check instead. Details in docs/ORIGINALS.md.

bannerwave
bannerwave
A bright front reveals the text while every column rides a travelling sine, then the text lies flat.
burnout
burnout
Exit effect: the text holds, then burns away through ember colours, shades and rising sparks.
comet
comet
Characters fly arcs from the bottom of the canvas on fading trails, land bright and cool into place.
copper
copper
Copper bars bounce behind dimmed text, lighting whole rows, then a sweep settles the final colours.
rotozoom
rotozoom
The demoscene rotozoomer: the text, tiled endlessly, spins while the zoom breathes, then locks into place.
stack
stack
Falling tetrominoes turn and lock into letters. A highlight sweeps out from the centre of each completed row, leaving its final gradient.

Benchmarks

Startup is under a millisecond (about 0.3 ms for glyphfx --version). The full 37-effect matrix against ttfx's engines: fx, the fastest port and glyphfx's target; the removed assembly engine, for the record; and the Rust 0.3.3 engine that is glyphfx's byte-parity oracle:

Best-of-N total run time at 200×50 with pacing disabled (--frame-rate 0), seed 1, on x86_64:12th Gen Intel(R) Core(TM) i5-12400. Speedups above 1.00× mean glyphfx is faster.

effect glyphfx ttfx (fx) vs fx ttfx (asm) vs asm ttfx (Rust) vs Rust
beams 74.3 ms 18.7 ms 0.25× 25.6 ms 0.34× 320.8 ms 4.32×
binarypath 774.9 ms 166.9 ms 0.22× 355.4 ms 0.46× 1512.1 ms 1.95×
blackhole 296.0 ms 98.3 ms 0.33× 116.6 ms 0.39× 784.1 ms 2.65×
bouncyballs 121.9 ms 50.8 ms 0.42× 64.3 ms 0.53× 527.5 ms 4.33×
bubbles 209.6 ms 73.9 ms 0.35× 94.2 ms 0.45× 799.7 ms 3.82×
burn 79.8 ms 34.3 ms 0.43× 52.7 ms 0.66× 598.9 ms 7.51×
colorshift 80.4 ms 36.7 ms 0.46× 33.1 ms 0.41× 644.1 ms 8.01×
crumble 203.3 ms 81.2 ms 0.40× 107.7 ms 0.53× 493.0 ms 2.42×
decrypt 86.4 ms 27.4 ms 0.32× 33.5 ms 0.39× 711.5 ms 8.23×
errorcorrect 49.5 ms 29.1 ms 0.59× 40.6 ms 0.82× 539.9 ms 10.91×
expand 82.4 ms 30.3 ms 0.37× 34.6 ms 0.42× 194.9 ms 2.37×
fireworks 309.0 ms 108.3 ms 0.35× 126.6 ms 0.41× 603.5 ms 1.95×
highlight 17.5 ms 5.2 ms 0.30× 7.1 ms 0.41× 69.8 ms 3.99×
laseretch 151.1 ms 102.9 ms 0.68× 105.3 ms 0.70× 912.8 ms 6.04×
matrix 91.6 ms 50.6 ms 0.55× 56.7 ms 0.62× 260.9 ms 2.85×
middleout 71.1 ms 16.5 ms 0.23× 20.0 ms 0.28× 142.2 ms 2.00×
orbittingvolley 65.9 ms 26.3 ms 0.40× 32.6 ms 0.49× 105.7 ms 1.60×
overflow 79.8 ms 22.8 ms 0.29× 23.3 ms 0.29× 156.8 ms 1.96×
pour 72.3 ms 31.4 ms 0.43× 37.6 ms 0.52× 394.0 ms 5.45×
print 36.5 ms 13.0 ms 0.36× 14.7 ms 0.40× 566.6 ms 15.52×
rain 92.5 ms 34.2 ms 0.37× 44.7 ms 0.48× 306.1 ms 3.31×
randomsequence 18.3 ms 6.2 ms 0.34× 8.2 ms 0.45× 74.4 ms 4.07×
rings 785.7 ms 156.4 ms 0.20× 201.8 ms 0.26× 926.7 ms 1.18×
scattered 127.8 ms 42.0 ms 0.33× 49.4 ms 0.39× 239.8 ms 1.88×
slice 57.5 ms 15.9 ms 0.28× 18.7 ms 0.33× 107.3 ms 1.87×
slide 67.6 ms 24.7 ms 0.37× 29.1 ms 0.43× 132.3 ms 1.96×
smoke 41.4 ms 13.6 ms 0.33× 21.7 ms 0.52× 279.3 ms 6.75×
spotlights 201.0 ms 49.0 ms 0.24× 49.1 ms 0.24× 437.7 ms 2.18×
spray 115.0 ms 47.7 ms 0.41× 55.2 ms 0.48× 221.6 ms 1.93×
swarm 735.7 ms 167.8 ms 0.23× 194.4 ms 0.26× 1044.8 ms 1.42×
sweep 19.9 ms 7.5 ms 0.38× 10.5 ms 0.53× 104.2 ms 5.24×
synthgrid 35.2 ms 10.6 ms 0.30× 12.8 ms 0.36× 170.7 ms 4.85×
thunderstorm 52.1 ms 26.6 ms 0.51× 36.4 ms 0.70× 522.6 ms 10.03×
unstable 178.9 ms 49.8 ms 0.28× 59.3 ms 0.33× 309.4 ms 1.73×
vhstape 155.7 ms 42.9 ms 0.28× 57.9 ms 0.37× 532.9 ms 3.42×
waves 84.9 ms 32.1 ms 0.38× 36.9 ms 0.43× 902.4 ms 10.63×
wipe 18.5 ms 5.3 ms 0.29× 7.1 ms 0.38× 66.5 ms 3.59×

Reproduce with python3 tools/tests/matrix.py (GLYPHFX_TTFX_FX names a ttfx >= 0.5 binary for the fx column, GLYPHFX_TTFX_ASM a build of ttfx 73c7a44 for the asm column), and make perf to gate against regression.

Usage

<producer> | glyphfx [terminal options] <effect> [effect options]

glyphfx --help                 # the 37 effects, the 6 originals, and the terminal options
glyphfx                        # the same, when nothing is piped in
glyphfx <effect> --help        # options for one effect
glyphfx --random-effect        # surprise me (--include-effects / --exclude-effects to filter)
glyphfx --print-completion bash|zsh

Terminal options (canvas size and anchoring, color handling, frame rate, text wrapping) go before the effect name; effect options after it. Option names, defaults, metavars, choices, negative-value handling, and nargs match ttfx, so existing invocations work with the binary name swapped.

On a colour terminal the help opens with the glyphfx wordmark, drawn by the highlight effect. Piped, or under NO_COLOR, TERM=dumb or --no-color, it is plain text, one option per line. A pipe with nothing in it still prints NO INPUT., as ttfx does.

Building

libc and libm only.

make            # build/glyphfx
make check      # unit tests (pure-function, geometry, gradient, RNG goldens)
make debug      # ASan/UBSan build
make install    # PREFIX=/usr/local by default
make static     # static link (build/glyphfx-static)

Fidelity

Given the same input, options, and seed, glyphfx produces byte-identical frames and a byte-identical terminal stream to ttfx, verified mechanically against the ttfx binary rather than by eye:

make parity     # M0 input/canvas/anchoring option matrix
make effects    # every effect's frame stream across seeds and configs
tools/tests/cli_corpus.sh    # exit codes and stdout/stderr routing
tools/tests/tty_compare.py   # the full pty prep+frames+teardown stream
tools/tests/tty_signals.py   # SIGINT/SIGTERM/close/resize behavior

The six originals have no oracle to match; make originals checks that they are deterministic, match their recorded golden streams, and end on the right final frame.

The oracle is a local ttfx checkout, fetched on demand and gitignored:

tools/parity/fetch_reference.sh

make effects expects reference/target/release/ttfx unless GLYPHFX_TTFX is set. A single effect runs with tools/parity/run_effects.sh <effect>.

Scope

Linux and macOS. Byte-exact comparison is pinned to Linux/glibc; builds and the unit tests also run on macOS.

Project facts

repo_facts.db is a nisaba store: an append-only, temporal key-value log of this project's decisions, benchmarks, releases and verification results, committed on purpose so the claims in this repository carry provenance rather than living in chat. Read it with the nisaba CLI:

nisaba repo_facts.db canon project.release.latest    # current value of one key
nisaba repo_facts.db scan perf                        # everything under a prefix
nisaba repo_facts.db history perf.milestone.v1_0_0    # how a claim changed

The log is the source of truth; repo_facts.db.idx, if present, is a disposable index cache and is not committed.

Credit

glyphfx is a C port of ttfx, which is a Rust port of TerminalTextEffects by ChrisBuilds. The effect set, the animation engine, and the command-line interface are TerminalTextEffects' design; ttfx is the reference glyphfx matches byte for byte.

License

MIT. See LICENSE; attribution is in NOTICE.

About

Pure-C17 parity port of ttfx: terminal text effects

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages