render: stage 2

This commit is contained in:
vova-rs committed 2026-09-16 00:11:56 +03:00
1 parent ac9f7fede4
commit 9ab067ae7d
2 files changed
+64 -24

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
pub enum BoardColor {
Solid(char),
Checkerboard(char, char),
}
pub fn render_u64(a: u64) {
let mut p: u64 = 1 << 56;
for _ in 0..8 {
for x in 0..8 {
if (p << x as u64) & a == 0 {
print!("0");
} else {
print!("1");
}
}
p = p >> 8;
print!("\n")
}
}
pub fn render_board(background: BoardColor, layers: Vec<(u64, char)>){
let mut p: u64 = 1 << 56;
for y in 0..8 {
for x in 0..8 {
if let Some((_, ch)) = layers.iter().find(|(a, _)| (p << x as u64) & a > 0) {
print!("{}", ch)
} else {
match background {
BoardColor::Solid(a) => {
print!("{}", a)
},
BoardColor::Checkerboard(a, b) => {
if (x + y) % 2 == 0 {
print!("{}", a)
} else {
print!("{}", b)
}
}
}
}
}
p = p >> 8;
print!("\n")
}
}