This commit is contained in:
wittmannzl103469 committed 2026-11-05 15:08:42 +01:00
1 parent de41a02749
commit 9af09cebd3
764 files changed
+54218 -78859

No files matched your search

@@ -1,5 +1,5 @@
#!/usr/bin/env python
"""pygame.examples.arraydemo
""" pygame.examples.arraydemo
Welcome to the arraydemo!
@@ -16,7 +16,7 @@ This demo will show you a few things:
import os
import pygame
import pygame as pg
from pygame import surfarray
main_dir = os.path.split(os.path.abspath(__file__))[0]
@@ -24,19 +24,19 @@ main_dir = os.path.split(os.path.abspath(__file__))[0]
def surfdemo_show(array_img, name):
"displays a surface, waits for user to continue"
screen = pygame.display.set_mode(array_img.shape[:2])
screen = pg.display.set_mode(array_img.shape[:2], 0, 32)
surfarray.blit_array(screen, array_img)
pygame.display.flip()
pygame.display.set_caption(name)
pg.display.flip()
pg.display.set_caption(name)
while True:
e = pygame.event.wait()
e = pg.event.wait()
# Force application to only advance when main button is released
if e.type == pygame.MOUSEBUTTONUP and e.button == pygame.BUTTON_LEFT:
if e.type == pg.MOUSEBUTTONUP and e.button == pg.BUTTON_LEFT:
break
elif e.type == pygame.KEYDOWN and e.key == pygame.K_s:
pygame.image.save(screen, name + ".png")
elif e.type == pygame.QUIT:
pygame.quit()
elif e.type == pg.KEYDOWN and e.key == pg.K_s:
pg.image.save(screen, name + ".png")
elif e.type == pg.QUIT:
pg.quit()
raise SystemExit()
@@ -45,7 +45,7 @@ def main():
import numpy as np
from numpy import int32, uint
pygame.init()
pg.init()
print("Using Numpy")
print("Press the left mouse button to advance image.")
@@ -64,8 +64,8 @@ def main():
surfdemo_show(striped, "striped")
# rgbarray
imagename = os.path.join(main_dir, "data", "arraydemo.webp")
imgsurface = pygame.image.load(imagename)
imagename = os.path.join(main_dir, "data", "arraydemo.bmp")
imgsurface = pg.image.load(imagename)
rgbarray = surfarray.array3d(imgsurface)
surfdemo_show(rgbarray, "rgbarray")
@@ -113,7 +113,7 @@ def main():
surfdemo_show(xfade, "xfade")
# all done
pygame.quit()
pg.quit()
if __name__ == "__main__":