Last active
February 19, 2025 18:04
-
-
Save tombh/9a80f7f13e7dffb69be7db4a79ed1cdf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const RESET: &str = "\x1b[m"; | |
/// Print all the colours of the terminal to STDOUT. | |
fn print_native_palette() { | |
println!("╭─────────────────╮"); | |
for y in 0u8..8 { | |
print!("│"); | |
print_true_colour_full_bg(255, y, 0); | |
print_true_colour_full_bg(0, 0, 255); | |
for x in 0u8..15 { | |
let background_colour = (y * 32) + x; | |
let foreground_colour = background_colour + 16; | |
print!("\x1b[48;5;{background_colour}m\x1b[38;5;{foreground_colour}m▄{RESET}"); | |
} | |
print!("│"); | |
println!(); | |
} | |
println!("╰─────────────────╯"); | |
} | |
/// Prints a true colour that completely fills the terminal cell's background. | |
/// Used to help orient ourselves when parsing the palette screenshot. | |
fn print_true_colour_full_bg(red: u8, green: u8, blue: u8) { | |
print!("\x1b[48;2;{red};{green};{blue}m "); | |
} | |
fn main() { | |
print_native_palette(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment