pub struct Surface {
pub base: f32,
pub quantum: f32,
}Expand description
What the layout is being drawn on: a base unit, and the smallest step the surface can actually represent.
Both are in the surface’s own units, and the crate never assumes those are pixels. A display measures in pixels and can represent one of them; a terminal measures in cells and cannot represent less than one. That single difference is the whole of the terminal story — a TUI is not a density, it is a surface with a coarse quantum, and the relational vocabulary above crosses over untouched.
Quantising is not a terminal special case. A display does it too; it is just that rounding 6.0 to the nearest pixel is uninteresting, whereas rounding three eighths of a cell to the nearest cell is a design decision the surface makes for you.
Fields§
§base: f32The base unit, in this surface’s units.
quantum: f32The smallest step this surface can represent, in the same units.
Implementations§
Source§impl Surface
impl Surface
Sourcepub fn terminal() -> Self
pub fn terminal() -> Self
A terminal measuring in cells: a one-cell base, one-cell quantum.
The coarsest surface in the family, and the one that proves the
vocabulary. bound and peer collapse to no cells at all, which is
correct — in a grid this dense, “belongs to” and “is a peer of” are
both expressed by adjacency, not by a gap.
Sourcepub fn resolve(self, ratio: Ratio) -> f32
pub fn resolve(self, ratio: Ratio) -> f32
Resolve a ratio on this surface, snapped to its quantum.