chore: 首次纳入版本控制(审查前基线,v1.2.0)
This commit is contained in:
@@ -0,0 +1,225 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""小学版 PRD 用的两张图:业务流程图 + 三屏线框图。
|
||||
|
||||
画布逻辑宽 680,SCALE=4 超采样,插入 Word 后正文约 6.8–7.5pt,打印可读。
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
HERE = Path(__file__).parent
|
||||
W = 680
|
||||
S = 4
|
||||
FONT = r"C:\Windows\Fonts\msyh.ttc"
|
||||
FONTB = r"C:\Windows\Fonts\msyhbd.ttc"
|
||||
|
||||
ACCENT = (179, 39, 45)
|
||||
INK = (34, 34, 34)
|
||||
MUTED = (120, 120, 120)
|
||||
LINE = (208, 208, 208)
|
||||
CARD = (250, 250, 250)
|
||||
PARENT = (242, 233, 232)
|
||||
CHILD = (233, 240, 236)
|
||||
SYS = (238, 240, 244)
|
||||
|
||||
|
||||
def F(size, bold=False):
|
||||
return ImageFont.truetype(FONTB if bold else FONT, int(size * S))
|
||||
|
||||
|
||||
def canvas(h):
|
||||
return Image.new("RGB", (W * S, h * S), "white")
|
||||
|
||||
|
||||
def rect(d, box, fill=None, outline=None, w=1, r=6):
|
||||
x0, y0, x1, y1 = [v * S for v in box]
|
||||
d.rounded_rectangle([x0, y0, x1, y1], radius=r * S, fill=fill,
|
||||
outline=outline, width=int(w * S))
|
||||
|
||||
|
||||
def line(d, pts, color=LINE, w=1):
|
||||
d.line([(x * S, y * S) for x, y in pts], fill=color, width=int(w * S))
|
||||
|
||||
|
||||
def arrow(d, pts, color=ACCENT, w=1.4, head=7):
|
||||
line(d, pts, color, w)
|
||||
(x0, y0), (x1, y1) = pts[-2], pts[-1]
|
||||
if abs(x1 - x0) >= abs(y1 - y0):
|
||||
s = 1 if x1 > x0 else -1
|
||||
d.polygon([(x1 * S, y1 * S), ((x1 - s * head) * S, (y1 - head * 0.55) * S),
|
||||
((x1 - s * head) * S, (y1 + head * 0.55) * S)], fill=color)
|
||||
else:
|
||||
s = 1 if y1 > y0 else -1
|
||||
d.polygon([(x1 * S, y1 * S), ((x1 - head * 0.55) * S, (y1 - s * head) * S),
|
||||
((x1 + head * 0.55) * S, (y1 - s * head) * S)], fill=color)
|
||||
|
||||
|
||||
def txt(d, xy, s, size=10, bold=False, color=INK, anchor="la"):
|
||||
d.text((xy[0] * S, xy[1] * S), s, font=F(size, bold), fill=color, anchor=anchor)
|
||||
|
||||
|
||||
def center(d, box, s, size=10, bold=False, color=INK):
|
||||
cx = (box[0] + box[2]) / 2
|
||||
cy = (box[1] + box[3]) / 2
|
||||
d.text((cx * S, cy * S), s, font=F(size, bold), fill=color, anchor="mm")
|
||||
|
||||
|
||||
def fit_size(s, max_w, size, bold=False):
|
||||
while size > 5:
|
||||
f = F(size, bold)
|
||||
if f.getlength(s) <= max_w * S:
|
||||
return size
|
||||
size -= 0.5
|
||||
return size
|
||||
|
||||
|
||||
def card(d, box, title, sub=None, fill=CARD, edge=LINE, tsize=10.5):
|
||||
rect(d, box, fill=fill, outline=edge, w=1, r=6)
|
||||
rect(d, (box[0], box[1], box[0] + 3, box[3]), fill=ACCENT, outline=None, r=0)
|
||||
tw = box[2] - box[0] - 12
|
||||
ts = fit_size(title, tw, tsize, True)
|
||||
if sub:
|
||||
txt(d, (box[0] + 9, box[1] + 8), title, ts, True, INK)
|
||||
ss = fit_size(sub, tw, 9, False)
|
||||
txt(d, (box[0] + 9, box[1] + 26), sub, ss, False, MUTED)
|
||||
else:
|
||||
center(d, box, title, fit_size(title, tw, tsize, True), True, INK)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ 业务流程图
|
||||
def make_flow():
|
||||
h = 330
|
||||
im = canvas(h)
|
||||
d = ImageDraw.Draw(im)
|
||||
|
||||
txt(d, (20, 12), "小学版业务流程:一条错题从「拍下来」到「签个字」", 13, True, ACCENT)
|
||||
txt(d, (20, 34), "八步,全部发生在放学后 19:30–20:00 这半小时里;颜色区分是谁在做。", 9, False, MUTED)
|
||||
|
||||
steps = [
|
||||
("拍作业", "家长", PARENT),
|
||||
("自动批改", "系统", SYS),
|
||||
("勾选不会", "家长", PARENT),
|
||||
("入库排期", "系统", SYS),
|
||||
("口答", "孩子", CHILD),
|
||||
("判对错", "系统", SYS),
|
||||
("同类 3 道", "孩子", CHILD),
|
||||
("打印复盘单", "家长", PARENT),
|
||||
]
|
||||
|
||||
bw, gap = 74, 6
|
||||
x0, y0, bh = 22, 62, 86
|
||||
boxes = []
|
||||
for i, (title, who, color) in enumerate(steps):
|
||||
x = x0 + i * (bw + gap)
|
||||
box = (x, y0, x + bw, y0 + bh)
|
||||
boxes.append(box)
|
||||
rect(d, box, fill=color, outline=None, r=6)
|
||||
rect(d, (box[0], box[1], box[2], box[1] + 3), fill=ACCENT, outline=None, r=0)
|
||||
center(d, (box[0], box[1] + 12, box[2], box[1] + 40),
|
||||
title if len(title) <= 4 else title[:4], 9.5, True, INK)
|
||||
if len(title) > 4:
|
||||
center(d, (box[0], box[1] + 34, box[2], box[1] + 52), title[4:], 9.5, True, INK)
|
||||
txt(d, (box[0] + 6, box[1] + bh - 22), "第 %d 步" % (i + 1), 7, False, MUTED)
|
||||
txt(d, (box[0] + 6, box[1] + bh - 12), who, 7.5, True, ACCENT)
|
||||
|
||||
if i < len(steps) - 1:
|
||||
ax = box[2]
|
||||
ay = box[1] + bh / 2 - 8
|
||||
arrow(d, [(ax + 1, ay), (ax + gap - 1, ay)], ACCENT, 1.2, 5)
|
||||
|
||||
# 时间轴
|
||||
line(d, [(22, 168), (658, 168)], LINE, 1)
|
||||
txt(d, (22, 174), "19:30 放学后", 8, False, MUTED)
|
||||
txt(d, (300, 174), "每天 5 分钟(固定 5 道,到点结束)", 8, True, ACCENT, anchor="ma")
|
||||
txt(d, (560, 174), "周日 3 分钟(打印 + 签字)", 8, False, MUTED)
|
||||
|
||||
rect(d, (20, 200, 660, 314), fill=(251, 244, 243), outline=(227, 200, 198), w=1, r=6)
|
||||
txt(d, (32, 210), "为什么必须是这八步(三条设计约束)", 10, True, ACCENT)
|
||||
txt(d, (32, 230), "① 单手可完成:家长另一只手可能在做饭,任何需要双手/横屏的步骤都放不进这半小时。", 8.5, False, INK)
|
||||
txt(d, (32, 250), "② 固定 5 道:一道一屏,做完即结束;追加第 6 道,第二天家长就不打开了。", 8.5, False, INK)
|
||||
txt(d, (32, 270), "③ 终点是纸:一周的成果必须落到一张能签字的 A5 上,否则家长无法向老师/自己交差。", 8.5, False, INK)
|
||||
txt(d, (32, 292), "注意:系统只做「判」和「排」,不做「教」——小学的讲解必须由家长读出来,机器念题孩子会走神。", 8.5, True, MUTED)
|
||||
|
||||
out = HERE / "prd_flow.png"
|
||||
im.save(out)
|
||||
print("已生成", out.name, im.size)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ 原型线框
|
||||
def make_wire():
|
||||
h = 430
|
||||
im = canvas(h)
|
||||
d = ImageDraw.Draw(im)
|
||||
|
||||
txt(d, (20, 12), "三个核心页面的线框(不是视觉稿,只定结构与交互)", 13, True, ACCENT)
|
||||
txt(d, (20, 34), "左:家长端首页 中:口答模式(横屏,孩子看) 右:A5 复盘单(打印预览)", 9, False, MUTED)
|
||||
|
||||
# --- 面板 1:家长端首页
|
||||
p1 = (20, 62, 200, 366)
|
||||
rect(d, p1, fill="white", outline=LINE, w=1.2, r=10)
|
||||
rect(d, (20, 62, 200, 92), fill=ACCENT, outline=None, r=10)
|
||||
rect(d, (20, 84, 200, 92), fill=ACCENT, outline=None, r=0)
|
||||
txt(d, (32, 72), "今天 · 5 道", 10.5, True, (255, 255, 255))
|
||||
txt(d, (32, 100), "已连续 3 天", 8.5, False, MUTED)
|
||||
rows = [
|
||||
("口算 · 第 3 题", "上次错 2 次"),
|
||||
("口算 · 第 4 题", "上次错 1 次"),
|
||||
("竖式 · 第 5 题", "上次错 3 次"),
|
||||
("应用题 · 多一步", "上次错 1 次"),
|
||||
("生字词 · 听写", "待复习"),
|
||||
]
|
||||
for i, (tx, sub) in enumerate(rows):
|
||||
y = 116 + i * 36
|
||||
rect(d, (30, y, 190, y + 30), fill=CARD, outline=LINE, w=0.8, r=5)
|
||||
txt(d, (38, y + 5), tx, 8.5, True, INK)
|
||||
txt(d, (38, y + 18), sub, 7.5, False, MUTED)
|
||||
txt(d, (30, 296), "2 道粗心错已移到「粗心小记」,不进今天", 7, False, ACCENT)
|
||||
rect(d, (30, 314, 190, 344), fill=ACCENT, outline=None, r=6)
|
||||
center(d, (30, 314, 190, 344), "开始(约 5 分钟)", 9, True, (255, 255, 255))
|
||||
txt(d, (30, 350), "周日:生成复盘单 ›", 8, False, MUTED)
|
||||
|
||||
# --- 面板 2:口答模式(横屏)
|
||||
p2 = (216, 106, 476, 286)
|
||||
rect(d, p2, fill=(252, 252, 252), outline=LINE, w=1.2, r=10)
|
||||
txt(d, (228, 116), "第 2 / 5 题 口算", 8.5, False, MUTED)
|
||||
center(d, (216, 130, 476, 190), "36 + 47 = ?", 26, True, INK)
|
||||
rect(d, (234, 200, 344, 236), fill="white", outline=LINE, w=1, r=6)
|
||||
center(d, (234, 200, 344, 236), "再想想", 9.5, True, MUTED)
|
||||
rect(d, (352, 200, 462, 236), fill=ACCENT, outline=None, r=6)
|
||||
center(d, (352, 200, 462, 236), "我说完了", 9.5, True, (255, 255, 255))
|
||||
txt(d, (228, 246), "家长读题 → 孩子口答 → 家长点「我说完了」", 8, False, MUTED)
|
||||
txt(d, (228, 260), "屏幕不显示答案,只显示对 / 再想想", 8, False, MUTED)
|
||||
|
||||
# --- 面板 3:A5 复盘单
|
||||
p3 = (492, 62, 660, 366)
|
||||
rect(d, p3, fill="white", outline=LINE, w=1.2, r=4)
|
||||
txt(d, (504, 72), "第 12 周 · 复盘单", 9.5, True, INK)
|
||||
txt(d, (504, 88), "9 月 2 日 – 9 月 8 日", 7.5, False, MUTED)
|
||||
line(d, [(504, 102), (648, 102)], LINE, 0.8)
|
||||
txt(d, (504, 108), "本周弄明白 5 道:", 8, True, INK)
|
||||
for i in range(3):
|
||||
y = 124 + i * 34
|
||||
rect(d, (504, y, 648, y + 26), fill=CARD, outline=LINE, w=0.6, r=4)
|
||||
txt(d, (510, y + 4), ["① 口算 36+47", "② 竖式 405-128", "③ 应用题 分铅笔"][i], 7.5, False, INK)
|
||||
txt(d, (510, y + 15), "我的做法:____________", 7, False, MUTED)
|
||||
txt(d, (504, 232), "还有 2 道没弄明白:", 8, True, ACCENT)
|
||||
txt(d, (504, 248), "④ 应用题 · 多一步 ⑤ 竖式 · 进位", 7.5, False, MUTED)
|
||||
line(d, [(504, 276), (648, 276)], LINE, 0.8)
|
||||
txt(d, (504, 284), "家长签字:__________", 8, False, INK)
|
||||
txt(d, (504, 302), "孩子的话:__________", 8, False, INK)
|
||||
txt(d, (504, 330), "(A5 一张,可对折夹进联系本)", 7, False, MUTED)
|
||||
|
||||
# 标注
|
||||
for x, s in ((20, "① 家长端 · 今日任务"), (216, "② 口答模式 · 横屏"), (492, "③ A5 复盘单")):
|
||||
txt(d, (x, 380), s, 9.5, True, INK)
|
||||
txt(d, (20, 398), "三个页面共用一条规则:任何一页都不出现「排行榜」「积分」「打卡」——小学的对手不是别人家孩子,是家长的时间。", 8.5, False, MUTED)
|
||||
|
||||
out = HERE / "prd_wire.png"
|
||||
im.save(out)
|
||||
print("已生成", out.name, im.size)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
make_flow()
|
||||
make_wire()
|
||||
Reference in New Issue
Block a user