laer细节参考 - 指南
本文概述laer的python实现的代码细节的本质语义。
overview
% CubeElement
creat_pack.py
make_pack.py
% MapElement
creat_map.py
make_map.py
check_map.py
% Lib
% src
% ce
% pack
% me
% map
% Laer
laer.py
% view
CubeElement
creat_pack.py
input("...").split()
按空格切割输入字面量为列表。os.makedirs("...", exist_ok=True)
创建目录但允许原目录存在。Image.new("RGBA", (w, h), (0, 0, 0, 0))
根据两个参数创建一个新的RGBA图形。draw = ImageDraw.Draw(template)
guide_color = (220, 220, 220, 255)
for x in range(15, w, 16): draw.line([(x, 0), (x, h)], fill=guide_color, width=1)
for y in range(15, h, 16): draw.line([(0, y), (w, y)], fill=guide_color, width=1)
在Image类上绘制灰色线条。template.save("...")
Image类的保存。with open(f"...", "w") as f: f.write("_")
在本地新建一个文件。
make_pack.py
cubes = []
创建集合类型。with open(f"Lib/ce/{pack}.ce", "r") as f:
_for line in f:
__line = line.strip()
__if not line or line.startswith("#"): continue
__parts = line.split()
__x = int(parts[0])
__y = int(parts[1])
__cube = " ".join(parts[2:])
__cubes.append((x, y, cube))
Rail脚本的CE解析。... .crop(...)
Image类的裁剪。
MapElement
creat_map.py
_
make_map.py
with open(f"Lib/map/{name}.json", "w") as f: json.dump(data, f, indent=4)
集合类型的数据存储为json。
check_map.py
... .show()
Image类型的预览。
Lib
src
_
ce
_
pack
_
me
_
map
_
Laer
laer.py
... .paste(...)
含alpha通道的粘贴。
view
_