mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-08-07 22:17:07 +02:00
43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
use crate::*;
|
|
use ratatui::{prelude::{Style, Position, Backend, Color}};
|
|
|
|
pub const fn x_repeat (c: &str) -> impl Draw<Tui> {
|
|
thunk(move|to: &mut Tui|{
|
|
let XYWH(x, y, w, _h) = to.xywh();
|
|
for x in x..x+w {
|
|
if let Some(cell) = to.0.cell_mut(Position::from((x, y))) {
|
|
cell.set_symbol(&c);
|
|
}
|
|
}
|
|
Ok(Some(XYWH(x, y, w, 1)))
|
|
})
|
|
}
|
|
|
|
pub const fn y_repeat (c: &str) -> impl Draw<Tui> {
|
|
thunk(move|to: &mut Tui|{
|
|
let XYWH(x, y, _w, h) = to.xywh();
|
|
for y in y..y+h {
|
|
if let Some(cell) = to.0.cell_mut(Position::from((x, y))) {
|
|
cell.set_symbol(&c);
|
|
}
|
|
}
|
|
Ok(Some(XYWH(x, y, 1, h)))
|
|
})
|
|
}
|
|
|
|
pub const fn xy_repeat (c: &str) -> impl Draw<Tui> {
|
|
thunk(move|to: &mut Tui|{
|
|
let XYWH(x, y, w, h) = to.xywh();
|
|
let a = c.len();
|
|
for (_v, y) in (y..y+h).enumerate() {
|
|
for (u, x) in (x..x+w).enumerate() {
|
|
if let Some(cell) = to.0.cell_mut(Position::from((x, y))) {
|
|
let u = u % a;
|
|
cell.set_symbol(&c[u..u+1]);
|
|
}
|
|
}
|
|
}
|
|
Ok(Some(XYWH(x, y, w, h)))
|
|
})
|
|
}
|
|
|