pub struct RenderedBlock { /* private fields */ }Expand description
A rectangular character grid with dimensional metadata.
This is the core data structure for 2D math rendering. Each cell contains a string (to handle multi-codepoint grapheme clusters). The baseline marks the row used for horizontal alignment when composing blocks side-by-side.
Implementations§
Source§impl RenderedBlock
impl RenderedBlock
Sourcepub fn new(cells: Vec<Vec<String>>, baseline: usize) -> Self
pub fn new(cells: Vec<Vec<String>>, baseline: usize) -> Self
Create a new block from rows of cell strings.
Width is computed from the first row (all rows must have equal width).
The baseline defaults to height / 2 if not specified.
pub fn width(&self) -> usize
pub fn height(&self) -> usize
pub fn baseline(&self) -> usize
pub fn cells(&self) -> &[Vec<String>]
pub fn is_empty(&self) -> bool
Sourcepub fn beside(&self, other: &RenderedBlock) -> RenderedBlock
pub fn beside(&self, other: &RenderedBlock) -> RenderedBlock
Place two blocks side-by-side, aligned on baselines. Pads the shorter block with empty rows above/below as needed.
Sourcepub fn above(
top: &RenderedBlock,
bottom: &RenderedBlock,
baseline_row: usize,
) -> RenderedBlock
pub fn above( top: &RenderedBlock, bottom: &RenderedBlock, baseline_row: usize, ) -> RenderedBlock
Stack two blocks vertically. The baseline is set to baseline_row
(typically the dividing row between them, or top/bottom block’s baseline).
Sourcepub fn pad(
&self,
left: usize,
right: usize,
top: usize,
bottom: usize,
) -> RenderedBlock
pub fn pad( &self, left: usize, right: usize, top: usize, bottom: usize, ) -> RenderedBlock
Add empty space around a block.
Sourcepub fn center_in(&self, target_width: usize) -> RenderedBlock
pub fn center_in(&self, target_width: usize) -> RenderedBlock
Horizontally centre a block within a given width.
Sourcepub fn hline(ch: char, width: usize) -> RenderedBlock
pub fn hline(ch: char, width: usize) -> RenderedBlock
Create a horizontal line of a given character and width.
Trait Implementations§
Source§impl Clone for RenderedBlock
impl Clone for RenderedBlock
Source§fn clone(&self) -> RenderedBlock
fn clone(&self) -> RenderedBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more