The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.



The pinstripes should either follow the system palette sequence,   or a sequence that includes:

black,   red,   green,   blue,   magenta,   cyan,   yellow,   and   white:

   after filling the top quarter, switch to a wider 2 pixel wide vertical pinstripe pattern,
   halfway down the display, switch to 3 pixel wide vertical pinstripe,
   finally to a 4 pixels wide vertical pinstripe for the last quarter of the display.


See also

   display black and white 
   print colour


my ($x,$y) = 1280, 720;
 
my @colors = map -> $r, $g, $b { [$r, $g, $b] },
     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 "pinstripes.ppm", :w orelse die "Can't create pinstripes.ppm: $_";
 
$img.print: qq:to/EOH/;
    P3
    # pinstripes.ppm
    $x $y
    255
    EOH
 
my $vzones = $y div 4;
for 1..4 -> $width {
    my $stripes = ceiling $x / $width / +@colors;
    my $row = [flat ((@colors Xxx $width) xx $stripes).map: *.values].splice(0,$x);
    $img.put: $row for ^$vzones;
}
 
$img.close;