Image noise: Difference between revisions
m
→{{header|EasyLang}}
(→C++) |
|||
(9 intermediate revisions by 5 users not shown) | |||
Line 1,218:
1400 to 1600 FPS
</pre>
=={{header|EasyLang}}==
[https://easylang.dev/show/#cod=XZDBqoMwEEX3fsWhi0dLaRp1UbPw/Yi4kDSCUI3EUPTvH9EE+roImTl3Zm4ys7OaeTGelQ2NQGSAti/r0CEc7duwcqcUBdtxB+6M9khRhpOJzE500zB23gSxd1xr8hAOPcu2+GE03PCS38jT6FzyqCI4bG9FTHeLSlLI//p3f5V0b1YfvO+cPz0v/HCin5dTqpPU6VUR9Y6afU5aQNNS0yClRClFu//LOtZQiLeUuUrN1rElnKuE4WO19tW4bnoOk6doY4E4/ET2Bw== Run it]
<syntaxhighlight>
proc pset x y c . .
color c
move x / 3.2 y / 3.2
rect 0.3 0.3
.
on animate
fr += 1
if systime - t0 >= 1
move 10 78
color -2
rect 80 20
color -1
move 10 80
text fr / (systime - t0) & " fps"
t0 = systime
fr = 0
.
col[] = [ 000 999 ]
for x = 0 to 319
for y = 0 to 199
pset x y col[randint 2]
.
.
.
</syntaxhighlight>
=={{header|Euler Math Toolbox}}==
Line 2,406 ⟶ 2,436:
createdialog testrollout
</syntaxhighlight>
=={{header|MiniScript}}==
This implementation is for use with [http://miniscript.org/MiniMicro Mini Micro].
<syntaxhighlight lang="miniscript">
clear
tileSetLength = 32
width = 320
height = 240
cellSize = [960/width, 600/height]
colors = [color.black, color.white]
newImg = function
img = Image.create(tileSetLength, 1)
for i in range(0, tileSetLength - 1)
img.setPixel i, 0, colors[rnd * 2]
end for
return img
end function
display(5).mode = displayMode.tile
td = display(5)
td.cellSize = cellSize
td.extent = [width, height]
td.tileSetTileSize = 1
for x in range(0, width - 1)
for y in range(0, height - 1)
td.setCell x, y, rnd * tileSetLength
end for
end for
frames = 0
startTime = time
while true
td.tileSet = newImg
frames += 1
dt = time - startTime
if dt >= 1 then
text.row = 25; print "FPS: " + round(frames / dt, 2)
frames = 0
startTime = time
end if
end while
</syntaxhighlight>
[[File:Minimicro-noise-32.gif]]
=={{header|Nim}}==
Line 2,985 ⟶ 3,058:
<syntaxhighlight lang="python">import time
import random
import
from PIL import Image
from PIL import ImageTk
class App:
def __init__(self, size, root):
self.root = root
self.root.title("Image Noise Test")
self.img = Image.new("
self.label =
self.label.pack()
Line 3,000 ⟶ 3,075:
self.frames = 0
self.size = size
self.n_pixels = self.size[0] * self.size[1]
self.loop()
def loop(self):
self.
[255 if b > 127 else 0 for b in random.randbytes(self.n_pixels)]
)
self.bitmap_image = ImageTk.BitmapImage(self.img)
self.label["image"] = self.bitmap_image
end_time = time.time()
self.time += end_time - start_time
self.frames += 1
if self.frames == 30:
try:
except ZeroDivisionError:
self.time = 0
self.frames = 0
self.root.after(1, self.loop)
def main():
root =
app = App((320, 240), root)
root.mainloop()
if __name__ == "__main__":
main()
</syntaxhighlight>
=={{header|Racket}}==
Line 3,173 ⟶ 3,251:
end /*y*/ /* [↑] build the image. */
return</syntaxhighlight>
=={{header|RPL}}==
RPL can only handle 131x64 screens. Despite such a small size, displaying graphics is very slow: FPH (frames Per Hour) would be a more appropriate unit.
====HP 28/48 version====
≪ TICKS (0,0) PMIN (130,64) PMAX
'''DO'''
CLLCD
'''IF''' TICKS OVER - 8192 / B→R '''THEN'''
LAST INV 3 DISP '''END'''
0 130 '''FOR''' x
0 63 '''FOR''' y
'''IF''' RAND 0.5 > '''THEN''' x y R→C PIXEL '''END'''
'''NEXT NEXT'''
'''UNTIL''' 0 '''END'''
≫ '<span style="color:blue">NOISE</span>' STO
HP-28 users shall replace <code>TICKS</code> by a <code>SYSEVAL</code> call, which address value depends on their ROM version.
====HP-48G version====
From the HP-48G model, the graphics system has been completely reviewed, and so the commands:
≪ TICKS
'''DO'''
ERASE
'''IF''' TICKS OVER - 8192 / B→R '''THEN'''
LASTARG INV 1 →GROB PICT RCL {#0h #42h} ROT GOR PICT STO {#0 #0} PVIEW '''END'''
0 130 '''FOR''' x
0 63 '''FOR''' y
'''IF''' RAND 0.5 > '''THEN''' x R→B y R→B 2 →LIST PIXON '''END'''
'''NEXT NEXT'''
{#0 #0} PVIEW
'''UNTIL''' 0 '''END'''
≫ '<span style="color:blue">NOISE</span>' STO
FPS = 0.0095
=={{header|Ruby}}==
Line 3,486 ⟶ 3,595:
=={{header|Wren}}==
{{libheader|DOME}}
<syntaxhighlight lang="
import "graphics" for Canvas, Color
import "random" for Random
|