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

That's a nice idea, but consider:

Only 2 of possible 16 colors are used.

Another problem: If there's an active conversation with 16 or more nicks (though unlikely), then the colors of the nicks change unexpectedly.

The question is, are this two disadvantages unavoidable?

Replies are listed 'Best First'.
Re^3: Coloring IRC logs nicely
by ikegami (Patriarch) on Aug 19, 2004 at 17:39 UTC
    A joins, color: 0/16
    B joins, color: 1/16
    (End)
    Only 2 of possible 16 colors are used.

    How is that a problem? There are only two people in the channel, so why whould you want to use more than two colours? People already in the channel when you start would be considered as people joining when they talk and have no colour assigned to them.

    Another problem: If there's an active conversation with 16 or more nicks (though unlikely), then the colors of the nicks change unexpectedly.

    Then use 32 colours instead of 16. And if 32 people are talking at the same time, I don't think colours are going to help you much. (That might even be true of 16.)

      Only 2 of possible 16 colors are used.
      How is that a problem? There are only two people in the channel, so why whould you want to use more than two colours? People already in the channel when you start would be considered as people joining when they talk and have no colour assigned to them.

      The problem is, that the contrast is not maximized. calc_color distributes all colors evenly over the whole color space. Example:

      If calc_color thinks there exist only two different persons, it will produce (e.g.) the colors #000000 and #ffffff. But if we tell calc_color that there're 16 different persons, we'll get #000000 and #111111. So, the contrast is not the maximum possible contrast.

      Then use 32 colours instead of 16. And if 32 people are talking at the same time, I don't think colours are going to help you much.

      True, haven't thought about that. So, Jaad's and davido's solutions fulfil their purpose -- Color nicks fast. If there're more people that available colors, that's a. bad luck and b. very unlikely.

      I just noticed that the case of not-using-all-available-colors is rare, too. So, it seems the pool-solutions are actually better than I first thought, thanks again Jaad and davido!

        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.
        So pick 32 (16, 24, whatever) colors you really like and let those be assiged in "roud-robin" as suggested.