Skip to content

Commit 4feae37

Browse files
committed
style: refresh terminal banner colors
1 parent f6a9c96 commit 4feae37

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

assets/mge-console-demo-en.gif

22.7 MB
Loading

crates/mge-cli/src/tui/banner.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ fn full_banner_lines(language: Language) -> Vec<Line<'static>> {
5050
.unwrap_or_default();
5151
let mut lines = BANNER_LINES
5252
.iter()
53-
.map(|line| Line::from(rainbow_banner_spans(line, banner_width)))
53+
.enumerate()
54+
.map(|(row, line)| Line::from(bright_diagonal_banner_spans(line, row)))
5455
.collect::<Vec<_>>();
5556
lines.push(Line::from(""));
5657
lines.push(Line::from(subtitle_spans(
@@ -127,17 +128,33 @@ fn centered_rainbow_spans(text: &str, available_width: usize) -> Vec<Span<'stati
127128
spans
128129
}
129130

130-
fn rainbow_banner_spans(line: &str, banner_width: usize) -> Vec<Span<'static>> {
131+
fn bright_diagonal_banner_spans(line: &str, row: usize) -> Vec<Span<'static>> {
131132
let mut spans = vec![Span::raw(BANNER_LEFT_PAD.to_string())];
132133
spans.extend(line.chars().enumerate().map(|(column, ch)| {
133134
Span::styled(
134135
ch.to_string(),
135-
Style::default().fg(rainbow_color(column, banner_width + 24)),
136+
Style::default().fg(bright_diagonal_color(column, row)),
136137
)
137138
}));
138139
spans
139140
}
140141

142+
fn bright_diagonal_color(column: usize, row: usize) -> Color {
143+
const PALETTE: &[(u8, u8, u8)] = &[
144+
(90, 255, 255),
145+
(20, 195, 255),
146+
(95, 105, 255),
147+
(185, 65, 255),
148+
(255, 45, 235),
149+
(255, 80, 135),
150+
(255, 215, 65),
151+
];
152+
153+
let band = ((column + row * 10) / 16) % PALETTE.len();
154+
let (red, green, blue) = PALETTE[band];
155+
Color::Rgb(red, green, blue)
156+
}
157+
141158
fn rainbow_color(position: usize, width: usize) -> Color {
142159
const STOPS: &[(u8, u8, u8)] = &[
143160
(97, 255, 255),
@@ -217,11 +234,11 @@ mod tests {
217234
}
218235

219236
#[test]
220-
fn banner_bottom_uses_same_horizontal_gradient_as_top() {
237+
fn banner_uses_bright_diagonal_color_bands() {
221238
let lines = banner_lines(Language::En, full_banner_min_width());
222-
let top_color = lines[0].spans[5].style.fg;
223-
let bottom_color = lines[5].spans[5].style.fg;
224-
assert_eq!(top_color, bottom_color);
239+
assert_eq!(lines[0].spans[7].style.fg, Some(Color::Rgb(90, 255, 255)));
240+
assert_eq!(lines[1].spans[7].style.fg, Some(Color::Rgb(20, 195, 255)));
241+
assert_ne!(lines[0].spans[7].style.fg, lines[1].spans[7].style.fg);
225242
}
226243

227244
#[test]

0 commit comments

Comments
 (0)