2026-06-11 21:31:37 -05:00
|
|
|
use color::Rgba8;
|
|
|
|
|
use ratatui::layout::Rect;
|
2026-06-11 21:55:53 -05:00
|
|
|
use ratatui::prelude::Color;
|
2026-06-11 21:31:37 -05:00
|
|
|
|
|
|
|
|
/// Converts a core [`Rgba8`] color into a ratatui truecolor [`Color`].
|
|
|
|
|
///
|
|
|
|
|
/// The alpha channel is dropped — terminals have no per-cell alpha. Truecolor
|
|
|
|
|
/// requires terminal support; terminals limited to 256 colors approximate it.
|
|
|
|
|
pub fn rgba8_to_color(c: Rgba8) -> Color {
|
|
|
|
|
Color::Rgb(c.r, c.g, c.b)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns true if two `Rect`s share at least one cell.
|
|
|
|
|
pub fn rects_overlap(a: Rect, b: Rect) -> bool {
|
2026-06-21 01:32:47 -05:00
|
|
|
a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height
|
|
|
|
|
}
|