use densa_core::{Color, Rect};
use densa_draw::Canvas;
pub(crate) fn outline(canvas: &mut Canvas<'_>, rect: Rect, width: f32, color: Color) {
let (l, t, r, b) = (rect.left(), rect.top(), rect.right(), rect.bottom());
canvas.fill_rect(Rect::from_edges(l, t, r, t + width), color);
canvas.fill_rect(Rect::from_edges(l, b - width, r, b), color);
canvas.fill_rect(Rect::from_edges(l, t + width, l + width, b - width), color);
canvas.fill_rect(Rect::from_edges(r - width, t + width, r, b - width), color);
}
pub(crate) fn centered(rect: Rect, width: f32, height: f32) -> densa_core::Point {
densa_core::Point::new(
(rect.left() + (rect.width() - width) / 2.0).round(),
(rect.top() + (rect.height() - height) / 2.0).round(),
)
}
pub(crate) fn luminance(color: Color) -> f32 {
0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b
}