用户:
你知道吗我2026回归了SR查看:0 回复:0 评论:0 创建时间:2022-03-28T19:26:23
【作品展示】

【作品介绍】
制作照片墙-钻石剑
【作品源代码】
# 照片墙-宝剑形状
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,1,1,1],
[0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1],
[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1],
[0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0],
[0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0],
[0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0],
[0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,0],
[0,0,0,1,1,1,0,1,1,1,1,0,0,0,0,0],
[0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0],
[0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0],
[0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0],
[0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0],
[0,0,0,1,1,1,0,1,1,1,1,0,0,0,0,0],
[0,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0],
[0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0],
[0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0]]
col = 16
row = 16
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('sword.png')
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn