Colour bars/Display: Difference between revisions
Content added Content deleted
m (→{{header|Go}}: Removed top and bottom blank lines from code window.) |
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: proper error message on file open failure, style tweaks) |
||
Line 984: | Line 984: | ||
close DISPLAY ;#to be watched with <image viewer> testprogram.png</lang> |
close DISPLAY ;#to be watched with <image viewer> testprogram.png</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 { Buf.new: |(($r, $g, $b) xx $ |
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 $ |
my $img = open "colorbars.ppm", :w orelse die "Can't create colorbars.ppm: $_"; |
||
$ |
$img.print: qq:to/EOH/; |
||
P6 |
P6 |
||
# colorbars.ppm |
# colorbars.ppm |
||
$ |
$x $y |
||
255 |
255 |
||
EOH |
EOH |
||
for ^$ |
for ^$y { |
||
for ^@colors -> $h { |
for ^@colors -> $h { |
||
$ |
$img.write: @colors[$h]; |
||
} |
} |
||
} |
} |
||
$ |
$img.close;</lang> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |