use pixtuoid_core::sprite::{Rgb, RgbBuffer};
use super::palette::blend_over;
pub(super) const WALL_THICK_V_PX: u16 = 3; pub(super) const WALL_THICK_H_PX: u16 = pixtuoid_core::layout::WALL_THICK_H;
const GLASS_SEAM_STRIDE: u16 = 16;
const GLASS_CAP_PX: u16 = WALL_THICK_H_PX;
fn glass_tones(theme: &crate::tui::theme::Theme) -> (Rgb, Rgb, Rgb) {
let tl = theme.office.room_wall_trim_light;
(
Rgb {
r: tl.r.saturating_add(125),
g: tl.g.saturating_add(135),
b: tl.b.saturating_add(124),
},
Rgb {
r: tl.r.saturating_add(70),
g: tl.g.saturating_add(100),
b: tl.b.saturating_add(116),
},
Rgb {
r: tl.r.saturating_add(18),
g: tl.g.saturating_add(52),
b: tl.b.saturating_add(86),
},
)
}
pub(super) fn stitch_vertical_wall(
start_y: u16,
end_y: u16,
top_margin: u16,
top_wall_h: u16,
h_rows: &[u16],
) -> (u16, u16) {
let y_top = if start_y == top_margin {
top_wall_h
} else if let Some(&hr) = h_rows
.iter()
.find(|&&hr| hr < start_y && start_y - hr <= WALL_THICK_H_PX + 2)
{
hr
} else {
start_y
};
let y_bot = if h_rows.contains(&end_y) {
end_y + (WALL_THICK_H_PX - 1)
} else {
end_y
};
(y_top, y_bot)
}
pub(super) fn paint_glass_wall_h(
buf: &mut RgbBuffer,
theme: &crate::tui::theme::Theme,
x0: u16,
x1: u16,
y_top: u16,
) {
let (hi, mid, lo) = glass_tones(theme);
let (bw, bh) = (buf.width, buf.height);
let cap_top = y_top.saturating_sub(GLASS_CAP_PX);
let rows = GLASS_CAP_PX + WALL_THICK_H_PX;
for x in x0..=x1.min(bw.saturating_sub(1)) {
let seam = (x - x0) % GLASS_SEAM_STRIDE == 0;
for i in 0..rows {
let y = cap_top + i;
if y >= bh {
continue;
}
let (g, a) = if seam {
(hi, 0.55)
} else if i == 0 {
(hi, 0.82)
} else if i == rows - 1 {
(lo, 0.72)
} else {
(mid, 0.58)
};
let color = blend_over(buf, x, y, g, a);
buf.put(x, y, color);
}
}
}
pub(super) fn paint_glass_wall_v(
buf: &mut RgbBuffer,
theme: &crate::tui::theme::Theme,
x_left: u16,
y_top: u16,
y_bot: u16,
) {
let (hi, mid, lo) = glass_tones(theme);
let (bw, bh) = (buf.width, buf.height);
for y in y_top..=y_bot.min(bh.saturating_sub(1)) {
let seam = (y - y_top) % GLASS_SEAM_STRIDE == 0;
for dx in 0..WALL_THICK_V_PX {
let x = x_left + dx;
if x >= bw {
continue;
}
let (g, a) = if seam {
(hi, 0.6)
} else if dx == 0 {
(hi, 0.85)
} else if dx == WALL_THICK_V_PX - 1 {
(lo, 0.72)
} else {
(mid, 0.6)
};
let color = blend_over(buf, x, y, g, a);
buf.put(x, y, color);
}
}
}