Pinstripe/Display: Difference between revisions

m
→‎{{header|Perl 6}}: proper error message on file open failure, style tweaks
(Added Perl example)
m (→‎{{header|Perl 6}}: proper error message on file open failure, style tweaks)
Line 692:
 
=={{header|Perl 6}}==
{{Works with|rakudo|20172018.0510}}
<lang perl6>my ($HORx,$y) = 1280,720;
my $VERT = 720;
 
my @colors = 0, 1;
 
spurt "pinstripes.pgm", qq:to/EOH/ orelse .die;
P5
# pinstripes.pgm
$HORx $VERTy
1
EOH
 
my $PGMimg = open "pinstripes.pgm", :a, :bin ororelse .die "Can't append to pinstripes.pgm: $!";
 
my $vzones = $VERTy div 4;
for 1..4 -> $w {
my $hzonesstripes = ceiling $HORx / $w / +@colors;
my $line = Buf.new: (flat((@colors Xxx $w) xx $hzonesstripes).Array).splice(0,$HORx); # DH change 2015-12-20
$PGMimg.write: $line for ^$vzones;
}
 
$PGMimg.close;</lang>
 
=={{header|Phix}}==
2,392

edits