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: | Line 776: | ||
close DISPLAY ;</lang> |
close DISPLAY ;</lang> |
||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{works with|Rakudo| |
{{works with|Rakudo|2018-10}} |
||
<lang perl6>my $ |
<lang perl6>my ($x,$y) = 1280, 720; |
||
my $VERT = 720; |
|||
my @colors = map -> $r, $g, $b { [$r, $g, $b] }, |
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 $ |
my $img = open "pinstripes.ppm", :w orelse die "Can't create pinstripes.ppm: $_"; |
||
$ |
$img.print: qq:to/EOH/; |
||
P3 |
P3 |
||
# pinstripes.ppm |
# pinstripes.ppm |
||
$ |
$x $y |
||
255 |
255 |
||
EOH |
EOH |
||
my $vzones = $ |
my $vzones = $y div 4; |
||
for 1..4 -> $ |
for 1..4 -> $width { |
||
my $ |
my $stripes = ceiling $x / $width / +@colors; |
||
my $ |
my $row = [((@colors Xxx $width) xx $stripes).flatmap: *.values].splice(0,$x); |
||
$ |
$img.put: $row for ^$vzones; |
||
} |
} |
||
$ |
$img.close;</lang> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |