A GPU-accelerated visualization library for large networks, such as power grids:
interactive views in the browser with WebGPU, and images and video from the command line.
npm install latkit # in the browser
cargo install latkit-cli # on the command line: pictures and video
cargo add latkit # in Rustimport { loadLatkit, Patch, field, type Scene } from 'latkit';
const { Data, Gpu } = await loadLatkit();
const data = new Data('grid').apply(
new Patch().replace('Bus', [101, 102], { x: [0, 30], y: [0, 20], kv: [230, 115] }),
);
const scene: Scene = {
space: 'plane',
marks: [
{
vertices: {
of: ['grid', 'Bus'],
position: ['x', 'y'],
radius: 6,
color: field('kv').colormap('viridis'),
},
},
],
};
const gpu = await Gpu.create();
const view = gpu.view(scene);
gpu.canvas(document.querySelector('canvas')!).show([view]);
view.setData(data);
view.fit();Scenes, expressions, and patches are plain data, typed from latkit's schema: latkit/core builds
them without loading WebAssembly, in a worker or on a server.
The same scene and data, as JSON, render to a picture, or with --frames to video:
latkit render scene.json --data grid.json --output grid.png
latkit render scene.json --data grid.json --frames frames.jsonl --fps 60 --output grid.mp4scene.json and grid.json
scene.json
{
"space": "plane",
"marks": [
{
"vertices": {
"of": ["grid", "Bus"],
"position": ["x", "y"],
"radius": 6,
"color": { "colormap": "viridis", "value": { "field": "kv" } }
}
}
]
}grid.json
{
"name": "grid",
"patch": [
{
"replace": {
"table": "Bus",
"ids": [101, 102],
"fields": { "x": [0, 30], "y": [0, 20], "kv": [230, 115] }
}
}
]
}Every picture is drawn by latkit; the examples hold them all with the code that draws them.
Guides, examples, and the reference are on Read the Docs; the Rust API is on docs.rs. Contributing covers the repository and how to build it.
Created by Luke Lowery. MIT License.






