Task

Display a series of vertical color bars across the width of the display.

The color bars should either use:

   the system palette,   or 
   the sequence of colors: 
   black
   red
   green
   blue
   magenta
   cyan
   yellow
   white


my ($x,$y) = 1280, 720;
 
my @colors = map -> $r, $g, $b { Buf.new: |(($r, $g, $b) xx $x div 8) },
      0,   0,   0,
    255,   0,   0,
      0, 255,   0,
      0,   0, 255,
    255,   0, 255,
      0, 255, 255,
    255, 255,   0,
    255, 255, 255;
 
my $img = open "colorbars.ppm", :w orelse die "Can't create colorbars.ppm: $_";
 
$img.print: qq:to/EOH/;
    P6
    # colorbars.ppm
    $x $y
    255
    EOH
 
for ^$y {
    for ^@colors -> $h {
        $img.write: @colors[$h];
    }
}
 
$img.close;