Skip to main content

Crate latkit

Crate latkit 

Source
Expand description

Columnar data drawn as vertices, edges, lines, and areas on the GPU.

A Data is a named collection of Tables, changed in place by Patches; a clone is an O(1) snapshot. A Scene describes what to draw and how it answers input: marks that name tables of data, in a space, with a theme and controls. A View draws a scene into any wgpu frame, is given the data by name, and turns platform Input into Events.

Every input is plain data that deserializes: from_json reads one from JSON text, an error naming the path to what it could not read, and schema gives its JSON Schema.

Modules§

host
What the platform does for latkit: set and measure text in its fonts, do jobs off the frame, fetch bytes (tiles, and the files JSON documents name), and encode video with its Encoder. A Gpu is given its host with Gpu::set_host; without one, views draw no text, do their jobs at once, fetch nothing, and encode no video. A browser’s host is Browser, built with the web feature for wasm32. Natively, the native feature supplies Native: lazy fonts, a worker pool doing jobs and reading files, and Media Foundation’s H.264 on Windows, without a window or network client.
resource
Fetching bytes for CPU data loading, independent of graphics and window systems.

Structs§

Areas
Rows drawn as the areas a polygon field holds: parcels, states, lakes, the land and water of a map. The view cuts each row’s polygons into triangles once, off the frame when they are large; on the earth they bend with the globe and stay whole across the antimeridian. Outline areas with a Lines mark of the same table, which draws their rings.
Axis
A plot axis.
Budget
How much GPU memory latkit uses.
Color
An sRGB color with straight alpha, each channel in 0..=1, as in CSS.
Colormap
Colors for a range of values: one of the catalog’s, or one of your own.
Controls
How a view answers the pointer and keyboard, and how much it moves on its own: a preset, or options over the defaults. Each mark says whether its rows pick, select, and drag; these say what the view itself does.
Data
A named collection of tables, changed in place by patches.
DecodeLimits
Limits for one binary frame. These bound encoded bytes and conservative decoded storage accounting; applying a patch and retaining datasets have separate memory costs.
Description
What a dataset holds: its tables, their rows and fields, and the axis its sampled fields are recorded over and span.
DeviceEvents
Receives events from an application-owned wgpu device without taking over its callbacks.
Diagram
A sheet for diagrams, flat and seen from straight above: the camera pans and zooms. Positions are units with y down, and every length is a unit, a CSS pixel at zoom 0 (sizes, padding, ports, strokes, text, and the theme’s), except glow, halo, and pick radius. Zooming scales one fixed picture. Only a diagram has ports, groups, nets, and orthogonal routes; it lays out blocks.
Earth
The earth: positions are longitude and latitude in degrees.
Edges
Rows drawn as strokes between the vertices two reference fields name: branches, links, wires. In a diagram, a row without ends is a net: it joins every vertex port whose reference field names it.
Encoding
A video: its pictures’ size in pixels, frames a second, and the bits a second an encoder spends.
End
A vertex a connection ends at, and its port when it has the one the connection meets.
Envelope
Rows’ least and greatest values of a sampled field over spans of its axis.
Expr
A value for every row of a mark: a constant, a field, view state, or arithmetic of them.
Faces
Rows drawn as triangles between the vertices three reference fields name: meshes, surfaces, and fields interpolated across a network. Faces are lit from the camera, so a flat mesh seen from above shows its exact colors.
FieldDescription
A field described: what it holds, the table a reference names, the coordinates samples span.
Flow
How comets flowing along edges and lines look: each a round head, brightest at its middle, trailing a tail that thins and fades.
Frame
A frame to draw: where, a texture view of a format and size in physical pixels at a ratio of physical pixels to CSS pixels, and when.
Gpu
The GPU device that views draw with. Cheap to clone; views of one Gpu share uploaded data.
Hit
A row under a point, as the frame drew it.
Ids
Row ids, as given to Table::new or Patch::remove, and the target ids of a reference.
Image
RGBA texels, straight alpha, sRGB, rows top to bottom.
Label
A row’s text, placed beside, inside, or along what its mark draws, following it every frame: a text field, or options. Labels that would overlap give way by priority; among equals, those already shown keep their place. In a diagram a label is part of the drawing: it scales with the zoom, fades out once too small to read, and shows wherever it fits its vertex.
Layered
Layered drawing: vertices in ranks, edges pointing along flow, and nets from their outputs.
Lines
Rows drawn as lines: along a path field (roads, rivers, borders) or a polygon field’s rings, outlining its areas; on a plot, through a sampled field’s history across the data’s axis, what a monitor shows. On the earth paths bend with the globe and stay whole across the antimeridian.
Mapped
A value mapped through a colormap or onto a range, whose domain can be set.
Modifiers
Keys held during an input.
Mp4
A Sink encoding H.264 with the host’s encoder and writing it to out as fragmented MP4 while frames are drawn. A frame lasts until the next one shows, so held frames cost nothing.
Name
The name of a dataset, table, or field: cheap to clone, compared and ordered by its text.
Panels
Where each of several views draws in a target: x, y, width, and height as fractions of it, a panel per view, in order; a later panel draws over an earlier one. None given is one view filling the target.
Patch
Changes to a dataset, applied in order and all at once by Data::apply.
Patches
Patches by dataset name, in the order written: what one step of a stream of changes carries, as JSON {"grid": [...], "weather": [...]}, each patch in Patch::load’s form.
Path
Where in an input an Error::Invalid occurred.
Pending
A value still to come: a future its Resolver resolves, from a view’s frames, a host’s worker, or the network. A view’s answers resolve to an error when the device is lost, and stay pending while no frames are drawn. Destroying their owner cancels them. Await it, or take it from a frame loop.
Plane
A plane: positions are plane units.
Plot
A plot: x is the data’s axis, y the values.
Port
A vertex’s port: where a net its reference field names meets it, on one side of its marker: a side, or options. An output drives its net: layouts rank a net from its outputs, and its arrows point away from them.
Query
The rows of a table to read back: of the rows ids names (every row unless set), those filter keeps, sorted by sort, a page of them from offset of at most limit, with the fields select names or computes; sampled fields read at axis coordinate at, their last frame by default. Plain data, like a scene.
Resolver
What resolves a Pending: a host keeps it until its job or fetch is done. Dropping it without resolving cancels the answer and wakes its waiter.
Row
A row of a table in a dataset. It survives any change that keeps the names and the id.
Rows
Rows of one table in a dataset, by id: what a view selects, fits, and tells as sets of rows.
Sample
A sample of a traced field: its frame, the axis coordinate it was recorded at, and its value.
Scene
What a view draws and how it answers input: a space, marks in drawing order, a layout, a theme, controls, how long changes ease, and the title written over it. Plain data: as JSON, each field by its name in camelCase, each mark { vertices | edges | faces | lines | areas: options }.
Shadow
How marks that cast shadows cast them onto the ground and onto faces.
Shot
A picture of views, each drawn into its panel of size pixels at scale pixels per CSS pixel: plain data, like a scene.
Size
A size: CSS pixels, or position units with units, kept within a range of CSS pixels.
Stats
What a view does each frame.
Stop
A colormap’s color, at a place from 0 to 1 or evenly between its neighbors: from a Color or a (place, Color) pair.
Stress
Stress majorization: each pair of vertices pulls toward its graph distance; then their boxes part, keeping a quarter of the gap clear.
Table
A named set of rows with fields: the rows of one type in a dataset, or rows to write into one.
TableDescription
A table described: its rows, and its fields by name.
Theme
Colors and sizes marks take where their options read nothing, and the look of focus and motion: a base theme’s name, or options over one (base, dark unless set). Lengths are CSS pixels; in a diagram they are units, except glow and halo.
Then
The cases of a when, waiting for another case or the value otherwise.
Tiles
Data a view fetches in pieces as it asks for them, kept as a dataset the view owns. Give them to a view with View::set_tiles; what the source’s first bytes hold says which they are.
Trigger
Where, with what keys, and with what the user acted. For keys, the point is the row they point at, else the pointer, else the view’s middle.
Values
One column of values, as given to Table::field or read from a page.
Vertices
Rows drawn as markers: points of a map, nodes of a graph, blocks of a diagram.
Video
A video of a shot’s pictures, handed to its sink while they are drawn.
View
A scene drawn from named data: the application owns data and scene; the view owns camera, coordinate, selection, and what the frame needs. It has no loop: render records a frame into an encoder the application submits, and input takes the platform’s pointer and keys.
Waiting
The work under way a frame stood in for, by kind; nothing when the frame was complete.
When
The open cases of a when.
Work
What a Gpu did since it was made; subtract two for what happened between.

Enums§

Button
A pointer button.
Camera
Where a view looks.
ColormapKind
How a colormap spans values.
Cursor
The pointer a view asks for over what it shows.
Device
What the user acts with.
Direction
A direction on screen.
Error
Everything that can go wrong in latkit.
Event
What happened in a view, for the application to act on. Drain them with View::events.
Fit
What View::fit frames.
Format
How an axis writes its tick values.
Grid
A plane’s or a diagram’s grid: "off", { lines: { pitch } }, or { dots: { pitch, snap } }.
Id
A row’s identity within its table: a number or a text. A number above 2^53 − 1 serializes as decimal text, which names the same row, since JSON readers such as JavaScript’s round it.
ImageFormat
How an image is written as a file.
Input
A pointer, wheel, or key event, with points in CSS pixels from the view’s top left.
Interpolation
How a line runs between its samples.
Key
The keys a view answers.
Kind
What a field holds.
Layout
How the view places vertex rows without positions: a diagram’s blocks, sized, or the points of a plane or the earth, among the rows linked to them, gaps in the space’s units: a name, or { stress | layered: options }. A place, once given, holds: rows added later are placed around the rest, and View::arrange lays every row out again.
Mark
One drawn table of a scene: { vertices | edges | faces | lines | areas: options } as JSON.
Marker
How a vertex is drawn: a shape’s name, "block", or { shape | block | gauge | pie | icon | wgsl: options }.
Motion
How much a view moves on its own.
Order
Which way a sort runs; rows a key reads nothing for come last either way.
Phase
The phase of a Drag.
Pixels
The bytes a picture is composed into.
Projection
How the earth is drawn.
Route
How an edge runs between its ends.
Shape
A marker’s outline.
Side
A side of a marker.
Space
The coordinate space a scene’s positions are in: a name, or { plane | diagram | earth | plot: options }. A diagram is a flat sheet seen from straight above: y runs down, and every length is a unit, a CSS pixel at zoom 0, except glow, halo, and pick radius. Only a diagram has ports, groups, nets, orthogonal routes, and layouts.
Step
One step of a Path: a named part or an index.
Value
One value read from a dataset.
Zoom
What zooms a view.

Traits§

Sink
What a video’s frames go to, in order: an Mp4 file, or whatever an application makes of the pixels.

Functions§

elapsed
Seconds since the view was created; a mark that reads it redraws every frame.
field
The field name of each row.
from_json
What JSON text holds, read as T: a scene, a camera, a fit, a query, rows, a budget, a shot, or any type that deserializes. An error names the path to what could not be read.
hovered
Whether the pointer is over the row.
pointer
CSS pixels from a vertex to the pointer; for vertices only, and not in their position.
schema
The JSON Schema of what T deserializes from, its definitions under $defs.
schemas
Every input’s JSON Schema in one document, each under its name in $defs with what it is built of: Scene, Data (a dataset’s document), Patch, Query, Camera, Fit, Budget, Shot. What latkit writes is under outputs, as it serializes: ViewEvent, Stats, Work, Description, Rows, Camera, Budget, Value, and Failure (an error).
selected
Whether the row is selected.
units
A size measured in position units, so it scales as the view zooms; Size::at_least and Size::at_most keep it within CSS pixels.
when
Starts a conditional: when(c).then(a).when(d).then(b).otherwise(e).
zoom
The camera’s zoom: the web mercator level on the earth, log₂ CSS pixels per unit elsewhere. Options that read it change with the view, as levels of detail do.

Type Aliases§

Result
A Result whose error is Error.