pub struct Globe<'a> { /* private fields */ }Expand description
A globe widget driven by an externally-provided Camera.
Renders by rasterizing land triangles and coastline contours into a shared
Braille dot grid (resolution 2W x 4H for a W x H cell area), then
composing each cell’s 8 dots into a single Braille glyph. Cells that
contain any contour dot render only the contour bits in
CONTOUR_COLOR - the land dots in those cells are dropped to preserve
the thin coastline. Cells with land but no contour render the land bits
in LAND_COLOR.
Vertices on the back hemisphere (post-rotation z < 0) are culled and
contour segments straddling the horizon are clipped to it. Triangles are
culled by the sign of their average vertex z (a sphere-tessellation
approximation of the surface normal direction).
Implementations§
Source§impl<'a> Globe<'a>
impl<'a> Globe<'a>
Sourcepub fn new(data: &'a MapData, camera: Camera) -> Self
pub fn new(data: &'a MapData, camera: Camera) -> Self
Examples found in repository?
examples/smoke.rs (line 19)
10fn main() {
11 let map = MapData::embedded();
12 let area = Rect::new(0, 0, 80, 30);
13 for yaw in [0.0_f32, 1.0, 2.0, 3.0] {
14 let camera = Camera {
15 yaw,
16 ..Camera::default()
17 };
18 let mut buf = Buffer::empty(area);
19 Globe::new(&map, camera).render(area, &mut buf);
20 println!("--- yaw = {yaw:.2} rad ---");
21 for y in 0..area.height {
22 let mut line = String::new();
23 for x in 0..area.width {
24 let sym = buf[(x, y)].symbol();
25 line.push(if sym == " " || sym.is_empty() {
26 ' '
27 } else {
28 '#'
29 });
30 }
31 println!("{}", line.trim_end());
32 }
33 println!();
34 }
35}Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Globe<'a>
impl<'a> RefUnwindSafe for Globe<'a>
impl<'a> Send for Globe<'a>
impl<'a> Sync for Globe<'a>
impl<'a> Unpin for Globe<'a>
impl<'a> UnsafeUnpin for Globe<'a>
impl<'a> UnwindSafe for Globe<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more