Data update

This commit is contained in:
Ingy döt Net 2023-12-16 21:33:55 -08:00
parent 35bcdeebf8
commit 74c69a0df6
2427 changed files with 31826 additions and 3468 deletions

View file

@ -0,0 +1,24 @@
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[random 2]
.
.
.

View file

@ -0,0 +1,37 @@
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

View file

@ -1,53 +1,58 @@
import time
import random
import Tkinter
import Image, ImageTk # PIL libray
import tkinter
from PIL import Image
from PIL import ImageTk
class App(object):
class App:
def __init__(self, size, root):
self.root = root
self.root.title("Image Noise Test")
self.img = Image.new("RGB", size)
self.label = Tkinter.Label(root)
self.img = Image.new("1", size)
self.label = tkinter.Label(root)
self.label.pack()
self.time = 0.0
self.frames = 0
self.size = size
self.n_pixels = self.size[0] * self.size[1]
self.loop()
def loop(self):
self.ta = time.time()
# 13 FPS boost. half integer idea from C#.
rnd = random.random
white = (255, 255, 255)
black = (0, 0, 0)
npixels = self.size[0] * self.size[1]
data = [white if rnd() > 0.5 else black for i in xrange(npixels)]
self.img.putdata(data)
self.pimg = ImageTk.PhotoImage(self.img)
self.label["image"] = self.pimg
self.tb = time.time()
start_time = time.time()
self.time += (self.tb - self.ta)
self.img.putdata(
[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:
self.fps = self.frames / self.time
except:
self.fps = "INSTANT"
print ("%d frames in %3.2f seconds (%s FPS)" %
(self.frames, self.time, self.fps))
fps = self.frames / self.time
except ZeroDivisionError:
fps = "INSTANT"
print(f"{self.frames} frames in {self.time:3.2f} seconds ({fps} FPS)")
self.time = 0
self.frames = 0
self.root.after(1, self.loop)
def main():
root = Tkinter.Tk()
root = tkinter.Tk()
app = App((320, 240), root)
root.mainloop()
main()
if __name__ == "__main__":
main()