Pseudorandom number generator image: Difference between revisions
Pseudorandom number generator image (view source)
Revision as of 11:51, 29 January 2024
, 3 months ago→{{header|Wren}}: Updated preamble and changed to Wren S/H
m (→{{header|jq}}: typo) |
(→{{header|Wren}}: Updated preamble and changed to Wren S/H) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 492:
writePgm(img, "prng_img.pgm", string.format("PRNG Image (%d x %d)", size, size))</syntaxhighlight>
=={{header|Maxima}}==
<syntaxhighlight lang="maxima">
genmatrix(lambda([i,j],random(1000)),1000,1000)$
wxdraw2d(image(%,0,0,30,30));
</syntaxhighlight>
[[File:PseudoRandomImageMaxima.png|thumb|center]]
=={{header|Nim}}==
Line 558 ⟶ 564:
(prin (if (rand T) 1 0)) )
(prinl) ) )</syntaxhighlight>
=={{header|Python}}==
'''Libraries:''' [https://pypi.org/project/Pillow/ Pillow], [https://docs.python.org/3/library/random.html random]<syntaxhighlight lang="python3">
# pseudorandom number image generator by Xing216
from random import randbytes
from PIL import Image
size = 1500
x = bytes.fromhex(" ".join([randbytes(3).hex() for x in range(size*size)]))
img = Image.frombuffer('RGB', (size, size), x, 'raw', 'RGB', 0, 1)
img.show()
</syntaxhighlight>'''Output:''' [https://transfer.sh/tyN5SS95M0/rcXing216.png rcXing216.png] (transfer.sh)
=={{header|Raku}}==
Line 600 ⟶ 617:
=={{header|Wren}}==
{{libheader|DOME}}
<syntaxhighlight lang="
import "graphics" for Canvas, Color
import "random" for Random
|