Pseudorandom number generator image: Difference between revisions
Pseudorandom number generator image (view source)
Revision as of 16:55, 19 August 2020
, 3 years agoupdate to perl & raku - thanks to SqrtNegInf for the image links ; my bad for the off-by-one bug ; I guess perl rounds toward zero so I change it too, please correct if it is wrong, thanks.
SqrtNegInf (talk | contribs) (Added Perl example) |
m (update to perl & raku - thanks to SqrtNegInf for the image links ; my bad for the off-by-one bug ; I guess perl rounds toward zero so I change it too, please correct if it is wrong, thanks.) |
||
Line 178:
for my $y(0..500) {
for my $x(0..500) {
my $color = $img->colorAllocate(rand
$img->setPixel($x, $y, $color);
}
Line 200:
my $o = Image::PNG::Portable.new: :width($_), :height($_);
for ^$_ X ^$_ -> @pixel { # about 40% slower if split to ($x,$y) or (\x,\y)
$o.set: @pixel[0], @pixel[1],
}
$o.write: "image$_.png" or die;
|