Skip to main content

smoke/
smoke.rs

1// SPDX-License-Identifier: GPL-3.0-or-later
2
3//! Renders one frame at several yaw angles into an in-memory ratatui Buffer
4//! and prints the result with `#` for any non-blank cell. Used to sanity-check
5//! the projection without running an interactive terminal.
6
7use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
8use tui_globe::{Camera, Globe, MapData};
9
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}