mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-12-26 12:01:45 +00:00
display grid as brightness characters
This commit is contained in:
parent
fa1ffab177
commit
18f07d6af4
18
src/cell.rs
18
src/cell.rs
@ -24,3 +24,21 @@ pub fn init_grid() -> Vec<Vec<Cell>> {
|
|||||||
}
|
}
|
||||||
grid
|
grid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn map_num(n: usize, s: usize, e: usize, a: usize, b: usize) -> usize {
|
||||||
|
(a as f64 + (n as f64 - s as f64) * (b as f64 - a as f64) / (e as f64 - s as f64)) as usize
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn display_grid(grid: &Vec<Vec<Cell>>) {
|
||||||
|
for i in 0..HEIGHT {
|
||||||
|
for j in 0..WIDTH {
|
||||||
|
let x = i as usize;
|
||||||
|
let y = j as usize;
|
||||||
|
let state = grid[x][y].state as usize;
|
||||||
|
|
||||||
|
let index = map_num(state, 0, Q, 0, BRIGHTNESS.len());
|
||||||
|
print!("{}", BRIGHTNESS.chars().nth(index).unwrap());
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user