GRAY, BL, OR = "#B9B9B4", "#406ED8", "#C8322B"
RD = OR
GCSS = f"""
.gc{{background:rgba(245,245,240,.9);border-radius:34px;padding:30px 50px 34px;box-shadow:0 12px 44px rgba(0,0,0,.35);display:flex;flex-direction:column;align-items:center;max-width:1640px}}
.gb{{position:absolute;left:120px;right:120px;top:96px;bottom:296px;display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center}}
.gt{{font-size:70px;font-weight:900;margin-bottom:40px;line-height:1.22;text-align:center}}
.gt small{{display:block;font-size:40px;font-weight:700;color:{SUB};margin-top:12px}}
.hb{{display:flex;align-items:center;margin:18px 0;width:1240px}}
.hb .l{{width:380px;font-size:48px;font-weight:700;text-align:right;padding-right:30px;line-height:1.15}}
.hb .l small{{display:block;font-size:32px;color:{SUB}}}
.hb .tr{{flex:1;position:relative;height:110px}}
.hb .bar{{position:absolute;left:0;top:0;bottom:0;border-radius:10px}}
.hb .v{{position:absolute;top:50%;font-size:68px;font-weight:900;white-space:nowrap}}
.box2{{background:#fff;border-radius:24px;padding:34px 18px;text-align:center;font-size:54px;font-weight:900;line-height:1.25;border:6px solid transparent;white-space:nowrap}}
.box2 small{{display:block;font-size:32px;font-weight:700;color:{SUB};margin-top:10px;white-space:normal}}
.arr{{font-size:60px;font-weight:900;color:{SUB};padding:0 6px;white-space:nowrap}}
.chip{{display:inline-block;background:#fff;border-radius:16px;padding:20px 26px;font-size:46px;font-weight:900;margin:10px}}
.hl2{{color:{OR}}} .bl2{{color:{BL}}}
"""
_G_USE = {}
def G(name, inner, title="", sub="", tag=None, ei_pose=None, poses=None, bg=None, ss=None):
"""図・グラフの場面。背景に映像を流し、半透明の板の上に図を描く。中身は画面の中央(x 960)にそろえる
(2026-11-26 エイイチの指示「テキストが右寄り → センター合わせ」)。板は y 786 までで、左下のハコブくんの区画に入らない"""
if bg is None:
bg = next(f for k, f in G_BG if name.startswith(k))
if ss is None:
ss = _G_USE.get(bg, 0); _G_USE[bg] = (ss + 4) % 20
t = f'
{title}' + (f'{sub}' if sub else '') + '
' if title else ''
html = overlay(f'')
if ei_pose:
html = add(html, ei_wipe(ei_pose, name, poses=poses))
S[name] = html
MOTION[name] = dict(type='html', bg=dict(file=bg, ss=ss, dim=0.7, slow=1.0), html=html)
def hbars(rows, maxv, t0=0.4, step=0.6, scale=0.68):
"""横の棒グラフ。rows=[(ラベル, 値, 色, 値の文字, 出す秒 or None)]。棒は左から伸ばす(write)"""
out = ''
for k, (lab, v, col, vt, *tt) in enumerate(rows):
t = tt[0] if tt and tt[0] is not None else round(t0 + k * step, 2)
w = max(v / maxv * scale * 100, 0.6)
out += (f'')
return out
def vbars(groups, maxv, series, t0=0.4, step=0.35, h=400, line=None):
"""縦の棒グラフ(場所ごとに2本など)。groups=[(ラベル, [値...])]、series=[(名前, 色)]。line=(値, 文字) で目安の破線"""
cols = ''
for g, (lab, vals) in enumerate(groups):
bars = ''
for s, v in enumerate(vals):
col = series[min(s, len(series) - 1)][1]
if isinstance(v, tuple):
v, col = v
t = round(t0 + (g * len(vals) + s) * step, 2)
hh = v / maxv * h
bars += (f'')
cols += (f'')
ln = ''
if line:
y = line[0] / maxv * h
ln = (f''
f'{line[1]}
')
leg = ''.join(f'{n}' for n, c in series)
return (f'{leg}
'
f'{ln}{cols}
')
def strip(cells, h=92, gap=7, t=0.4, dt=0.05, k=1.35):
"""時間の帯。cells=[(幅, 色, 文字)]。左から順に出す"""
out = ''
for i, (w, c, tx) in enumerate(cells):
out += (f'{tx}
')
return f'{out}
'
def row_lab(lab, inner, w=300):
return f''
def flow(boxes, arrows=None, t0=0.3, step=0.7, hi=None):
"""箱を矢印でつなぐ流れ図。boxes=[(文字, 小さい文字, 枠の色 or None, 出す秒 or None)]"""
out = ''
for k, (a, b, c, *tt) in enumerate(boxes):
t = tt[0] if tt and tt[0] is not None else round(t0 + k * step, 2)
bd = f'border-color:{c}' if c else ''
sm = f'{b}' if b else ''
if k:
ar = (arrows[k - 1] if arrows else '→')
out += f'{ar}
'
out += f'{a}{sm}
'
return f'{out}
'
def places(marks, t0=0.4, step=0.35, note=None):
"""5か所の結果(○ ✕)。marks=[(○ か ✕, 色, 出す秒 or None)]"""
out = ''
for k, (m, c, *tt) in enumerate(marks):
t = tt[0] if tt and tt[0] is not None else round(t0 + k * step, 2)
mk = f'' if m == '○' else m
out += (f'')
nt = f'{note}
' if note else ''
return f'{out}
{nt}'
def dots_n(n, red, t0, dt=0.05, size=78):
out = ''.join(f'' for k in range(n))
return f'{out}
'
def big(lines, sub=""):
sb = f'{sub}
' if sub else ''
return f''