Re: print in purple question

[email protected] (ToddAndMargo via perl6-users)
Newsgroups perl.perl6.users
Message-ID <[email protected]>
On 11/3/24 22:04, Bruce Gray wrote:
> 
> 
>> On Nov 3, 2024, at 22:12, ToddAndMargo via perl6-users <[email protected]> wrote:
>>
>> Hi All,
>>
>> Fedora 41
>> rakudo-pkg-2024.7.0-01.x86_64
>> bash-5.2.32-1.fc41.x86_64
>>
>> I am looking at
>>    https://metacpan.org/pod/Term::ANSIColor
>>
>> trying to figure out how to print in dark purple.
>> I have see dnf5 do this, so I know it is possible.
>>
>> Now one of the hurdles is that purple is not an
>> actual color.  It does not appear on a white
>> light spectrum break out.  Purple is a manifestation
>> of our brains interpreting a mixture of red and blue.
>>
>> So how do I mix red and blue to get dark purple?
>>
>> Many thanks,
>> -T
>>
> 
> Magenta is one of the standard ANSI terminal colors, so that is probably the color you are seeing in the `dnf` output as "purple".
> 
> Simplest example, using module:
> raku -e 'use Terminal::ANSIColor; say color("magenta"), "this is in purple(magenta)", color("reset");'
> 
> Just the four purples, in raw ANSI codes:
> raku -e 'say "\e\[{.[0]};{.[1]}m {.[0]};{.[1]} \e\[m " for (0,1) X (35,95);'
> 
> Full color grid:
> raku -e '
> my @fg = (31..37) X+ (0,60);
> my @bg = (41..47) X+ (0,60);
> say "    ", @bg.fmt("--%3d--", " ");
> for @fg -> $f {
>    print $f.fmt("%3d:");
>    for @bg -> $b {
>      for 0,1 -> $a {
>        my $z = "$a;$f;$b";
>        print "\e\[{$z}m $a \e\[m ";
>      }
>    }
>    say "";
> }'
> 
> For more info:
>      https://azrael.digipen.edu/~mmead/www/mg/ansicolors/index.html
> 

Hi Bruce,

Are the numbers in the "ANSI Escape Sequences (Details) " of the link,
hexidecimal by chance? "9" an "8" are not octal.

       Attributes	 Foreground          Background
                          color               color
       00 = normal	 31 = red	     40 = black
       01 = bold	         32 = green	     41 = red
       04 = underlined	 33 = orange	     42 = green
       05 = blinking	 34 = blue	     43 = orange
       07 = reversed	 35 = purple	     44 = blue
       08 = concealed	 36 = cyan	     45 = purple
	                 37 = grey	     46 = cyan
	                 90 = dark grey	     47 = grey
	                 91 = light red	     100 = dark grey
	                 92 = light green    101 = light red
	                 93 = yellow	     102 = light green
	                 94 = light blue     103 = yellow
	                 95 = light purple   104 = light blue
	                 96 = turquoise	     105 = light purple
                                              106 = turquoise

This is what I was after:

 > print color('bold'), color('52'), "abc", color('reset'), "\n";
abc  <shows dark purple>

Questions:

1) why is "color('bold')" = bold, and
           "color('01')    = normal?

2) why is "color('52')" (34 hex) dark purple and not blue?


Yours in confusion,
-T
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.