Colors & Styles
Rich terminal coloring with 16, 256, and true color support
Overview
ZFish provides powerful color and styling capabilities for terminal output
The style module offers comprehensive color support including:
- 16 basic ANSI colors
- 256-color palette
- True color (24-bit RGB) support
- Text styling (bold, italic, underline)
- Foreground and background colors
Basic Colors
16 standard ANSI colors
Basic Colors Example
use zfish::style::Color;
// Print with basic colors
print("Red text", Color::Red);
print("Green text", Color::Green);
print("Blue text", Color::Blue);
print("Yellow text", Color::Yellow);
// Bright variants
print("Bright red", Color::BrightRed);
print("Bright green", Color::BrightGreen);Output
Red textGreen textBlue textYellow textBright redBright green
256-Color Palette
Extended color palette with 256 colors
256-Color Example
use zfish::style::Color;
// Use 256-color palette with Custom(n)
println!("{}", Color::Custom(208).paint("Orange"));
println!("{}", Color::Custom(129).paint("Purple"));
println!("{}", Color::Custom(213).paint("Pink"));
println!("{}", Color::Custom(80).paint("Teal"));
// Colors range from 0-255
for i in [196, 202, 208, 214, 220, 226] {
println!("{}", Color::Custom(i).paint(format!("Color {}", i)));
}Output
Orange\nPurple\nPink\nTeal\nColor 196\nColor 202...
Combined Styles
Mix colors with multiple text styles
Combined Styles Example
use zfish::style::{Color, Style};
// Combine multiple styles
println!("{}", Color::Cyan
.paint("Bold + Italic + Underline")
.style(Style::Bold)
.style(Style::Italic)
.style(Style::Underline)
);
// Rainbow example
let rainbow_colors = [
Color::Red, Color::Yellow, Color::Green,
Color::Cyan, Color::Blue, Color::Magenta,
];
for color in rainbow_colors {
print!("{}", color.paint("āāāāā "));
}
println!();Output
Bold + Italic + Underline\nāāāāā āāāāā āāāāā āāāāā āāāāā āāāāā
Text Styling
Bold, italic, underline, and more
Text Styling Example
use zfish::style::{Color, Style};
// Apply styles using .style() method
println!("{}", Color::White.paint("Bold text").style(Style::Bold));
println!("{}", Color::White.paint("Italic text").style(Style::Italic));
println!("{}", Color::White.paint("Underlined").style(Style::Underline));
println!("{}", Color::White.paint("Dim text").style(Style::Dim));
// Available styles:
// Style::Bold, Style::Dim, Style::Italic
// Style::Underline, Style::Blink, Style::Reverse, Style::HiddenOutput
Bold text\nItalic text\nUnderlined\nDim text
Available Colors
All standard ANSI colors and custom palette
Available Colors
use zfish::style::Color;
// Standard colors
Color::Black, Color::Red, Color::Green, Color::Yellow
Color::Blue, Color::Magenta, Color::Cyan, Color::White
// Bright variants
Color::BrightBlack, Color::BrightRed, Color::BrightGreen
Color::BrightYellow, Color::BrightBlue, Color::BrightMagenta
Color::BrightCyan, Color::BrightWhite
// Custom 256-color (0-255)
Color::Custom(208) // Orange
Color::Custom(129) // PurpleAPI Reference
Available colors and methods
Basic Colors
BlackRedGreenYellowBlueMagentaCyanWhiteBrightBlackBrightRedBrightGreenBrightYellowBrightBlueBrightMagentaBrightCyanBrightWhite
Available Methods
paint(text)style(Style)Custom(n)