pub(crate) fn draw_line(
context: &mut crate::render::RenderContext,
rect: crate::core::Rect,
vertical: bool,
thickness: u32,
color: crate::core::Color,
) {
if rect.width == 0 || rect.height == 0 {
return;
}
let thickness = thickness.max(1);
let half = (thickness / 2) as i32;
if vertical {
let x =
rect.x + (rect.width as i32 / 2).clamp(half, (rect.width as i32 - 1 - half).max(half));
let top = rect.y + half;
let bottom = (rect.y + rect.height as i32 - 1 - half).max(top);
context.draw_line_stroke(
crate::core::Point::new(x, top),
crate::core::Point::new(x, bottom),
color,
thickness,
);
} else {
let y = rect.y
+ (rect.height as i32 / 2).clamp(half, (rect.height as i32 - 1 - half).max(half));
let left = rect.x + half;
let right = (rect.x + rect.width as i32 - 1 - half).max(left);
context.draw_line_stroke(
crate::core::Point::new(left, y),
crate::core::Point::new(right, y),
color,
thickness,
);
}
}