用户:谢子豪558查看:0 回复:1 评论:0 创建时间:2019-11-01T20:48:14
【作品展示】

【作品介绍】
上照片墙这一刻后,我自己为老师就是做了一份再见的作品,
【作品源代码】
import os
from PIL import Image
import matplotlib.pyplot as plt
myDir = 'BCM'
files = os.listdir(myDir)
images_ext = [".png", ".jpg", ".bmp", ".jpeg", ".gif"]
images = []
for file in files:
name, ext = os.path.splitext(file)
if ext in images_ext and 'bcm' in name:
img = Image.open(myDir+os.sep+file)
_img = img.resize((300, 300))
images.append(_img)
# print(images)
style = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0],
[0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0],
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0],
[0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0],
[0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0],
[0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
col=15
row=10
board = Image.new('RGBA', (300*col, 300*row))
for i in range(row):
for j in range(col):
if style[i][j]==1:
index = j+col*i
board.paste(images[index % len(images)], (j*300, i*300))
plt.imshow(board)
plt.show()
board.save('886.png')
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn