Pseudorandom number generator image: Difference between revisions
Pseudorandom number generator image (view source)
Revision as of 14:28, 19 August 2020
, 3 years agoAdded Perl example
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: link to generated image) |
SqrtNegInf (talk | contribs) (Added Perl example) |
||
Line 2:
;Task:
Write a program that creates an image from
The image can have the following dimensions:
::# 250px by 250px : If the algorithm requires the use of prime numbers, use 8-15 bit primes.
Line 168:
save("randombw.png", rand(Float16, 1000, 1000))
</lang>
=={{header|Perl}}==
<lang perl>use strict;
use warnings;
use GD;
my $img = new GD::Image(500, 500, 1);
for my $y(0..500) {
for my $x(0..500) {
my $color = $img->colorAllocate(rand 255, rand 255, rand 255);
$img->setPixel($x, $y, $color);
}
}
open F, "image500.png";
print F $img->png;</lang>
[https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/PNG-image500.png image500.png] (sample image, offsite)
=={{header|Raku}}==
|