Jump to content

Pseudorandom number generator image: Difference between revisions

Added Perl example
m (→‎{{header|Raku}}: link to generated image)
(Added Perl example)
Line 2:
 
;Task:
Write a program that creates an image from ana Pseudorandom Number Generator (PRNG) algorithm's output.
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}}==
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.