in reply to Re^4: Coloring IRC logs nicely
in thread Coloring IRC logs nicely

For fun, I created a table of colours. They're not as distinctive as I would have imagined. Maybe something more logarithmic (00,BB,FF instead of 00,80,FF, for example) would work better

use strict; use warnings; # # Gives (1 + 2^n)^3 - 1 colours, where n>=0 # # $n = 0 gives 7 colours. # $n = 1 gives 26 colours. # $n = 2 gives 728 colours. # my $n = 1; my @components; my @colours; { #my $inc = 256 / (1 << $n); my $inc = 256 >> $n; my $component = 0; do { push(@components, sprintf('%02X', $component)); $component += $inc; } while ($component < 256); push(@components, 'FF') unless ($components[$#components] eq 'FF'); } { my $r; my $g; my $b; foreach $r (@components) { foreach $g (@components) { foreach $b (@components) { push(@colours, "#$r$g$b"); }}} shift(@colours); # Remove background colour. } print(qq{<table bgcolor="#000000"><tr><td>\n}); print(qq{<font color="$_">This is a line of text in $_.</font><br>\n}) + foreach (@colours); print(qq{</td></tr></table>\n}); __END__ output: =======
This is a line of text in #000080.
This is a line of text in #0000FF.
This is a line of text in #008000.
This is a line of text in #008080.
This is a line of text in #0080FF.
This is a line of text in #00FF00.
This is a line of text in #00FF80.
This is a line of text in #00FFFF.
This is a line of text in #800000.
This is a line of text in #800080.
This is a line of text in #8000FF.
This is a line of text in #808000.
This is a line of text in #808080.
This is a line of text in #8080FF.
This is a line of text in #80FF00.
This is a line of text in #80FF80.
This is a line of text in #80FFFF.
This is a line of text in #FF0000.
This is a line of text in #FF0080.
This is a line of text in #FF00FF.
This is a line of text in #FF8000.
This is a line of text in #FF8080.
This is a line of text in #FF80FF.
This is a line of text in #FFFF00.
This is a line of text in #FFFF80.
This is a line of text in #FFFFFF.

Update: s/80/BB/g

This is a line of text in #0000BB.
This is a line of text in #0000FF.
This is a line of text in #00BB00.
This is a line of text in #00BBBB.
This is a line of text in #00BBFF.
This is a line of text in #00FF00.
This is a line of text in #00FFBB.
This is a line of text in #00FFFF.
This is a line of text in #BB0000.
This is a line of text in #BB00BB.
This is a line of text in #BB00FF.
This is a line of text in #BBBB00.
This is a line of text in #BBBBBB.
This is a line of text in #BBBBFF.
This is a line of text in #BBFF00.
This is a line of text in #BBFFBB.
This is a line of text in #BBFFFF.
This is a line of text in #FF0000.
This is a line of text in #FF00BB.
This is a line of text in #FF00FF.
This is a line of text in #FFBB00.
This is a line of text in #FFBBBB.
This is a line of text in #FFBBFF.
This is a line of text in #FFFF00.
This is a line of text in #FFFFBB.
This is a line of text in #FFFFFF.