Munching squares: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: put a gamma-ish curve on the color table)
Line 329: Line 329:


=={{header|Perl 6}}==
=={{header|Perl 6}}==
<lang perl6>my @scale = ^256;
<lang perl6>my @colors = map -> $r, $g, $b { Buf.new: $r, $g, $b },
my @colors = map -> $r, $g, $b { Buf.new: $r, $g, $b },
map -> $x { floor ($x/256) ** 3 * 256 },
((0...255) Z
((0...255) Z
(255...0) Z
(255...0) Z
(0,2...254),(254,252...0));
(0,2...254),(254,252...0));


my $PPM = open "munching.ppm", :w, :bin or die "Can't create munching.ppm: $!";
my $PPM = open "munching.ppm", :w, :bin or die "Can't create munching.ppm: $!";


Line 341: Line 342:
# munching.pgm
# munching.pgm
256 256
256 256
255
255
EOH
EOH

$PPM.write: @colors[$_] for @scale X+^ @scale;
$PPM.write: @colors[$_] for ^256 X+^ ^256;


$PPM.close;</lang>
$PPM.close;</lang>