Pseudorandom number generator image: Difference between revisions

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.
(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 255256, rand 255256, rand 255256);
$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], 255256.rand.Int, 255256.rand.Int, 255256.rand.Int
}
$o.write: "image$_.png" or die;
350

edits