Tiling algorithms (Luau scripts via the pluau standard library), TilingState, the algorithm registry, and the ILayoutSource adapter that publishes autotile output to the daemon.
Zones are static layouts the user draws in an editor. Autotiling is the dynamic counterpart: as windows open and close, a tiling algorithm recomputes the zone boundaries automatically. This library owns the algorithm vocabulary and the per-screen tiling state. The runtime engine that drives them lives in `phosphor-tile-engine`, and the generic Luau host (sandbox, watchdog, marshalling) lives in `phosphor-scripting`.
| Type | Purpose |
|---|---|
| PhosphorTiles::TilingAlgorithm | Abstract base; calculateZones(const TilingParams&) -> QVector<QRect> |
| PhosphorTiles::LuauTileAlgorithm | The concrete TilingAlgorithm that delegates to a Luau script |
| PhosphorTiles::TilingState | Per-screen window order + master count + split tree; implements IPlacementState |
| PhosphorTiles::SplitTree | Binary-split tree node + ratio used by tree-style algorithms |
| PhosphorTiles::ITileAlgorithmRegistry | Read-side contract; subclasses ILayoutSourceRegistry |
| PhosphorTiles::AlgorithmRegistry | Concrete catalogue of registered LuauTileAlgorithms |
| PhosphorTiles::ScriptedAlgorithmLoader | Discovers *.luau files, validates names, creates + registers LuauTileAlgorithms |
| PhosphorTiles::AutotileLayoutSource | ILayoutSource adapter wrapping a registry |
| PhosphorTiles::AutotileLayoutSourceFactory | Provider factory, registers with LayoutSourceProviderRegistry |
| PhosphorTiles::AutotilePreviewRender | Paint-a-thumbnail helper for the algorithm picker |
The pluau standard library (src/pluau/pluau.luau) and its type stubs (src/pluau/pluau.d.luau) are the Luau-side API surface. See the tiling algorithm authoring guide.
Discover and run the bundled + user Luau algorithms:
#include <PhosphorTiles/AlgorithmRegistry.h>
#include <PhosphorTiles/AutotileLayoutSource.h>
#include <PhosphorTiles/ScriptedAlgorithmLoader.h>
using namespace PhosphorTiles;
AlgorithmRegistry reg;
// Point a loader at an XDG-relative subdirectory and scan. The bundled
// algorithms live in the system data dir; user algorithms override by
// filename from the writable data dir. Each discovered *.luau registers a
// LuauTileAlgorithm against the injected registry.
ScriptedAlgorithmLoader loader(QStringLiteral("plasmazones/algorithms"), ®);
loader.scanAndRegister();
auto *alg = reg.algorithm(QStringLiteral("master-stack"));
AutotileLayoutSource src(®);
// … src is an ILayoutSource the same way ZonesLayoutSource is.A minimal Luau algorithm (e.g. $XDG_DATA_HOME/<app>/algorithms/vstack.luau):
-- Single column, each window gets an equal vertical slice.
local pluau = pluau
return pluau.algorithm {
metadata = {
name = "Vertical Stack",
id = "vstack",
description = "Single column, equal vertical slices",
minimumWindows = 1,
},
tile = function(ctx)
if ctx.windowCount <= 0 then
return {}
end
return ctx.area:rows(ctx.windowCount, ctx.innerGap)
end,
}