examples/ANSI Color Test/README.md
This example exercises Serial Studio's ANSI color and VT-100 terminal emulation support.
\033[48;5;Nm\033[38;2;R;G;Bm\033[48;2;R;G;Bm\033[1A) and cursor back (\033[3D) with overwrite\033[K)Configure Serial Studio:
Enable ANSI Colors:
Run the complete test script with all color tests:
python3 test_ansi_colors.py
The script sends a full suite of ANSI color and VT-100 test sequences to Serial Studio via UDP. Watch the console pane to see:
You can also run individual test sections:
# Text attributes (bold, italic, underline, ...)
python3 test_ansi_colors.py --attributes
# 16-color foreground, background, and FG x BG matrix
python3 test_ansi_colors.py --4bit
# 4-bit FG x BG color matrix only
python3 test_ansi_colors.py --matrix
# 256-color (8-bit) palette
python3 test_ansi_colors.py --256
# 24-bit truecolor ramps, gradients, HSV sweeps
python3 test_ansi_colors.py --truecolor
# Named truecolor samples (CSS/X11 reference)
python3 test_ansi_colors.py --named
# VT-100 cursor, erase, and attribute sequences
python3 test_ansi_colors.py --vt100
# 2D truecolor rendering test (sine-field plasma)
python3 test_ansi_colors.py --plasma
# Show help message
python3 test_ansi_colors.py --help
The script sends formatted test sequences as UDP datagrams to 127.0.0.1:9000. Each test section includes:
\033[38;2;255;20;147m)\033[30m Black \033[90m Bright Black
\033[31m Red \033[91m Bright Red
\033[32m Green \033[92m Bright Green
\033[33m Yellow \033[93m Bright Yellow
\033[34m Blue \033[94m Bright Blue
\033[35m Magenta \033[95m Bright Magenta
\033[36m Cyan \033[96m Bright Cyan
\033[37m White \033[97m Bright White
\033[40m Black BG \033[100m Bright Black BG
\033[41m Red BG \033[101m Bright Red BG
\033[42m Green BG \033[102m Bright Green BG
\033[43m Yellow BG \033[103m Bright Yellow BG
\033[44m Blue BG \033[104m Bright Blue BG
\033[45m Magenta BG \033[105m Bright Magenta BG
\033[46m Cyan BG \033[106m Bright Cyan BG
\033[47m White BG \033[107m Bright White BG
\033[38;5;Nm Set foreground to color N (0-255)
\033[48;5;Nm Set background to color N (0-255)
Color ranges:
\033[38;2;R;G;Bm Set foreground to RGB(R, G, B)
\033[48;2;R;G;Bm Set background to RGB(R, G, B)
Where R, G, B are values from 0-255.
Multiple codes can be combined with semicolons:
\033[31;47m Red text on white background
\033[1;32m Bold green text
\033[38;5;206;48;5;57m 8-bit pink on blue
\033[38;2;255;82;197;48;2;155;106;0m RGB pink on brown
\033[0m Reset all attributes (color, bold, etc.)
When you run the test, you should see colorful output in the Serial Studio console like:
[2] 4-bit Colors (16 standard ANSI colors)
────────────────────────────────────────────────────────────────
Foreground — normal (30–37):
Black \033[30m
Red \033[31m
Green \033[32m
...
Each color will be rendered in its actual color, with backgrounds displaying behind text.
You can modify test_ansi_colors.py to:
HOST/PORT constants, default 127.0.0.1:9000)Serial Studio's ANSI color implementation: