Plasma effect: Difference between revisions
→{{header|Perl}}: code simplifications
SqrtNegInf (talk | contribs) (Added Perl example) |
(→{{header|Perl}}: code simplifications) |
||
Line 1,093:
{{trans|Perl 6}}
<lang perl>use Imager;
my($width, $height) = (400, 400);▼
$img->write(file => 'run/plasma-perl6.png');▼
sub plasma {
my ($w, $h) = @_;
for my $x (0..$w){▼
my $img = Imager->new(xsize
my $hue = 4 + sin($x / 19) + sin($y / 9) + sin(($x + $y) / 25) + sin(sqrt($x**2 + $y**2) / 8);▼
▲ for my $x (0 .. $w-1) {
$img->setpixel( x => $x, y => $y, color => hsv2rgb($hue/8, 1, 1));▼
for my $y (0 .. $h-1) {
}
}
}
▲ return \@rgb;
Off-site image: [https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/plasma.png Plasma effect]
|