Colour pinstripe/Display: Difference between revisions

Content deleted Content added
SqrtNegInf (talk | contribs)
m →‎{{header|Perl 6}}: proper error message on file open failure, style tweaks
Line 776:
close DISPLAY ;</lang>
=={{header|Perl 6}}==
{{works with|Rakudo|20162018-0110}}
<lang perl6>my ($HORx,$y) = 1280, 720;
my $VERT = 720;
 
my @colors = map -> $r, $g, $b { [$r, $g, $b] },
0, 0, 0, 0,
255, 0, 0,
0, 255, 0,
0, 0, 0,255,
255, 0, 255,
0, 255, 255,
255, 255, 0,
255, 255, 255;
 
my $PPMimg = open "pinstripes.ppm", :w ororelse die "Can't create pinstripes.ppm: $!_";
 
$PPMimg.print: qq:to/EOH/;
P3
# pinstripes.ppm
$HORx $VERTy
255
EOH
 
my $vzones = $VERTy div 4;
for 1..4 -> $wwidth {
my $hzonesstripes = ceiling $HORx / $wwidth / +@colors;
my $linerow = [((@colors Xxx $wwidth) xx $hzonesstripes).flatmap: *.values].splice(0,$HORx);
$PPMimg.put: $linerow for ^$vzones;
}
 
$PPMimg.close;</lang>
 
=={{header|Phix}}==