pub struct LineNetwork { /* private fields */ }Expand description
One connected drawing whose horizontal and vertical segments form junctions.
Unlike crate::CanvasContext::line, a line network does not accept
diagonal segments or an arbitrary marker. Intersections are rendered as
corners, tees, and crossings selected from its LineGlyphs. Only
segments recorded in the same value contribute to those junctions;
separate Canvas commands combine through their recorded composition.
LineContinuations can add outward incidence at either endpoint without
adding a cell outside the segment’s inclusive range.
use urushi::{
CanvasContext, LineContinuations, LineGlyphs, LineNetwork, TextStyle,
};
fn draw(context: &mut CanvasContext) {
let mut network = LineNetwork::new(LineGlyphs::NORMAL, TextStyle::new());
network
.horizontal(1, 0..=4)
.vertical_with(2, 0..=2, LineContinuations::START);
context.line_network(network);
}Implementations§
Source§impl LineNetwork
impl LineNetwork
Sourcepub fn new(glyphs: LineGlyphs, style: TextStyle) -> Self
pub fn new(glyphs: LineGlyphs, style: TextStyle) -> Self
Creates an empty line network with one glyph repertoire and style.
§Panics
Panics if a repertoire character is not printable or does not occupy exactly one terminal cell.
Sourcepub fn horizontal(&mut self, y: i64, columns: RangeInclusive<i64>) -> &mut Self
pub fn horizontal(&mut self, y: i64, columns: RangeInclusive<i64>) -> &mut Self
Adds a horizontal segment at y, including both endpoints.
An empty range adds nothing.
Sourcepub fn horizontal_with(
&mut self,
y: i64,
columns: RangeInclusive<i64>,
continuations: LineContinuations,
) -> &mut Self
pub fn horizontal_with( &mut self, y: i64, columns: RangeInclusive<i64>, continuations: LineContinuations, ) -> &mut Self
Adds a horizontal segment with endpoint continuation at y.
START continues left from the first column and END continues right
from the last column. Continuation changes endpoint incidence without
drawing outside the inclusive range. An empty range adds nothing.
Sourcepub fn vertical(&mut self, x: i64, rows: RangeInclusive<i64>) -> &mut Self
pub fn vertical(&mut self, x: i64, rows: RangeInclusive<i64>) -> &mut Self
Adds a vertical segment at x, including both endpoints.
An empty range adds nothing.
Sourcepub fn vertical_with(
&mut self,
x: i64,
rows: RangeInclusive<i64>,
continuations: LineContinuations,
) -> &mut Self
pub fn vertical_with( &mut self, x: i64, rows: RangeInclusive<i64>, continuations: LineContinuations, ) -> &mut Self
Adds a vertical segment with endpoint continuation at x.
START continues up from the first row and END continues down from
the last row. Continuation changes endpoint incidence without drawing
outside the inclusive range. An empty range adds nothing.
Trait Implementations§
Source§impl Clone for LineNetwork
impl Clone for LineNetwork
Source§fn clone(&self) -> LineNetwork
fn clone(&self) -> LineNetwork
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LineNetwork
impl Debug for LineNetwork
Source§impl PartialEq for LineNetwork
impl PartialEq for LineNetwork
Source§fn eq(&self, other: &LineNetwork) -> bool
fn eq(&self, other: &LineNetwork) -> bool
self and other values to be equal, and is used by ==.