Pseudorandom number generator image: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: link to generated image) |
SqrtNegInf (talk | contribs) (Added Perl example) |
||
Line 2: | Line 2: | ||
;Task: |
;Task: |
||
Write a program that creates an image from |
Write a program that creates an image from a Pseudorandom Number Generator (PRNG) algorithm's output. |
||
The image can have the following dimensions: |
The image can have the following dimensions: |
||
::# 250px by 250px : If the algorithm requires the use of prime numbers, use 8-15 bit primes. |
::# 250px by 250px : If the algorithm requires the use of prime numbers, use 8-15 bit primes. |
||
Line 168: | Line 168: | ||
save("randombw.png", rand(Float16, 1000, 1000)) |
save("randombw.png", rand(Float16, 1000, 1000)) |
||
</lang> |
</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}}== |
=={{header|Raku}}== |