walkit
Rust · on crates.io · early · GPL-3.0-or-later · mattijsf/walkit · docs
walkit runs Winamp skins as a library. You give it a skin, and every frame it gives back a list
of things to draw. It handles classic skins (.wsz, the bitmaps of Winamp 2) and modern ones
(.wal, a zip of XML, images and compiled MAKI scripts). Alpaca uses it
for both.
cargo add walkit
The two skins in the repo, walkit-classic.wsz and walkit-modern.wal, drawn by walkit
through walkit-cli at 2×.
Engine and host
Section titled “Engine and host”The engine doesn’t touch files, the screen or the clock. The host provides those, along with fonts and input, and the engine asks for them when it needs them.
skin files ──► walkit ──► draw list ──► host renderer ▲ │ host services ───┘ └──► player commands, host actions (pictures, fonts, clock, input, player)- Files. The host opens the skin archive and passes its files in. A modern skin can sit on Winamp’s wasabi base, and a classic skin on a base skin that fills in bitmaps it leaves out.
- Pictures and text. The engine asks for a picture’s size and pixels, and for a text’s width and line metrics. A Rust host can use the engine’s TrueType renderer, which draws letters the way Winamp does.
- Clock. Every timer, animation and script reads one clock in milliseconds. An app passes wall time. A test steps the clock, and every run lands on the same frames.
- Player. The engine reads the player’s state (status, position, title, playlist, equalizer, visualizer data) and sends it commands like play, pause, seek and volume.
- Input. Pointer down, move and up, and double taps, in viewport pixels.
The host calls tick regularly. When it returns true, something changed and the host asks for
the frame. The engine runs on whichever thread calls it, one call at a time.
The draw list
Section titled “The draw list”A frame is a list of windows. Each window has a rect in viewport pixels and a list of draw commands in layout pixels, drawn in order.
| Command | What the host draws |
|---|---|
Image |
A bitmap or part of one, stretched to a rect at an opacity, tinted by the skin’s colour theme |
Fill |
A box in one colour |
Text |
A run of text in a font, size and colour, clipped to its box and positioned by the engine |
BitmapText |
Text in a skin’s bitmap font, as glyphs |
Clip, Unclip |
A clip rect around the commands in between |
WindowStart, WindowEnd |
A shaped window: what’s in between only shows inside its region |
Pixels |
A small ARGB picture: the visualizer, the equalizer graph, gradients |
A host that redraws only what changed can ask for a planned frame. It marks which parts of a window change from frame to frame, like a ticker or the visualizer, and gives the rest a version number to cache against. Across wasm or JNI, a frame travels as one packed buffer with only the commands that changed since the last one.
Modern skins contain compiled MAKI bytecode, and walkit has a VM to run it. When it’s unclear how a skin should look or behave, I set up the same state in Winamp 5.666 in a virtual machine and check against a screenshot or a probe there. Then a test pins the behaviour down.
Traces
Section titled “Traces”The engine can also write the draw list as text, one command per line:
fill 0,0,864,1632 #000000 a=255image window/window.png 100,23,5,5 -> 0,18,5,5 a=255text "A song title (3:45)" font=- size=13 #93afb9 a=255 88,24,136,20 x=88.00 base=34.40clip 0,0,864,1632pixels 22,52,72,16 72x16 a=255 crc=d22b684aunclipwalkit-trace runs a scripted scenario on a stepped clock and writes everything to such a
trace: each step, the skin’s log lines, menus, host actions and the draw list of every frame that
changed. Text is measured with fixed metrics, and the same scenario gives the same trace on every
platform. Before a release I diff the traces line by line against the previous release’s.
Crates and hosts
Section titled “Crates and hosts”| Path | What |
|---|---|
crates/walkit |
The engine: runtime, gui, maki, classic, and the draw list in draw, plan and packed |
crates/walkit-trace |
Runs scenarios and writes traces |
crates/walkit-web |
The engine as a wasm module |
crates/walkit-android |
The engine as libwalkit.so for the Kotlin API |
android/ |
The AAR, nl.mattix.walkit:walkit |
web/ |
The JavaScript host and the player page |
examples/ |
Small apps for the web, Android and macOS |
The documentation site has the host guides and the API reference.
No trackers or cookies. Older designs of this site.