Death Star: Difference between revisions
→{{header|Perl 6}}: better concurrency
Thundergnat (talk | contribs) (→{{header|Perl 6}}: modernize a bit, add concurrency) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: better concurrency) |
||
Line 1,012:
my $depth = 255; # image color depth
my $
my $s = ($
my @light = normalize([ 4, -1, -3 ]);
Line 1,035:
sub MAIN ($outfile = 'deathstar-perl6.pgm') {
spurt $outfile, ("P5\n$
my $out = open( $outfile, :a, :bin ) or die "$!\n";
say 'Working...';
Line 1,044:
sub draw_ds ( $k, $ambient ) {
my @pixels[$height];
my @row[$x];▼
(($pos.cy - $pos.r) .. ($pos.cy + $pos.r)).race.map: -> $y {
(($pos.cx - $pos.r) .. ($pos.cx + $pos.r))
# black if we don't hit positive sphere, ignore negative sphere
if not hit($pos, $x, $y, my $posz) {
Line 1,068 ⟶ 1,069:
@row[$x + $s] = ($intensity * $depth).Int min $depth;
}
@pixels
}
flat |@pixels.map: *.list;
}
|