Skip to content

Instantly share code, notes, and snippets.

@icktty
Last active March 16, 2021 04:51
Show Gist options
  • Save icktty/50bb1978da9d28846f9f631faf4f0a57 to your computer and use it in GitHub Desktop.
Save icktty/50bb1978da9d28846f9f631faf4f0a57 to your computer and use it in GitHub Desktop.
砂嵐(iOS Pythonista3) https://youtu.be/IRO1EqQQucA
from scene import *
from PIL import Image
from random import randrange
MAX_IMG_CNT = 16
class MyScene (Scene):
def setup(self):
scale = get_screen_scale()
self.screen_size = Size(self.size.w * scale, self.size.h * scale)
img_size = (int(self.size.w / 2), int(self.size.h / 2))
self.imgs = []
for i in range(MAX_IMG_CNT):
img = Image.new('L', img_size)
pix = img.load()
for y in range(img.height):
for x in range(img.width):
pix[x, y] = randrange(256)
self.imgs.append(img)
self.cnt = 0
def draw(self):
name = load_pil_image(self.imgs[self.cnt])
image(name, 0, 0, self.screen_size.w, self.screen_size.h)
unload_image(name)
next_cnt = randrange(MAX_IMG_CNT)
while self.cnt == next_cnt:
next_cnt = randrange(MAX_IMG_CNT)
self.cnt = next_cnt
if __name__ == '__main__':
run(MyScene(), LANDSCAPE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment