-
-
Save icktty/50bb1978da9d28846f9f631faf4f0a57 to your computer and use it in GitHub Desktop.
砂嵐(iOS Pythonista3) https://youtu.be/IRO1EqQQucA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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