| 139 | |
| 140 | |
| 141 | def write_svg() -> None: |
| 142 | parts = [ |
| 143 | f'<svg xmlns="http://www.w3.org/2000/svg" width="{W}" height="{H}" viewBox="0 0 {W} {H}">', |
| 144 | '<rect width="100%" height="100%" fill="white"/>', |
| 145 | ] |
| 146 | for tick in [12, 16, 20, 24, 28, 32, 36]: |
| 147 | x = LEFT + (tick - X_MIN) / (X_MAX - X_MIN) * (RIGHT - LEFT) |
| 148 | parts.append(f'<line x1="{x}" y1="{TOP - 25}" x2="{x}" y2="{BOTTOM + 15}" stroke="{rgb(GRID)}" stroke-width="1"/>') |
| 149 | parts.append( |
| 150 | f'<text x="{x}" y="{BOTTOM + 50}" font-family="Times New Roman" ' |
| 151 | f'font-size="20" text-anchor="middle" fill="{rgb(TEXT)}">{tick}M</text>' |
| 152 | ) |
| 153 | |
| 154 | parts.append(f'<line x1="{LEFT}" y1="{BOTTOM + 15}" x2="{RIGHT}" y2="{BOTTOM + 15}" stroke="{rgb(AXIS)}" stroke-width="2"/>') |
| 155 | parts.append( |
| 156 | f'<text x="{LEFT}" y="{BOTTOM + 84}" font-family="Times New Roman" ' |
| 157 | f'font-size="22" font-weight="700" fill="{rgb(TEXT)}">TokenCost (million tokens, lower is better)</text>' |
| 158 | ) |
| 159 | parts.append(f'<circle cx="{LEFT + 8}" cy="32" r="8" fill="{rgb(CLOSED)}"/>') |
| 160 | parts.append(f'<text x="{LEFT + 24}" y="39" font-family="Times New Roman" font-size="21" fill="{rgb(TEXT)}">Closed</text>') |
| 161 | parts.append(f'<circle cx="{LEFT + 128}" cy="32" r="8" fill="{rgb(OPEN)}"/>') |
| 162 | parts.append(f'<text x="{LEFT + 144}" y="39" font-family="Times New Roman" font-size="21" fill="{rgb(TEXT)}">Open</text>') |
| 163 | |
| 164 | for idx, (name, group, tokens) in enumerate(ROWS): |
| 165 | y = y_pos(idx) |
| 166 | x = x_pos(tokens) |
| 167 | color = color_for(group, name) |
| 168 | label_color = TEXT if name != "PaperFlow" else PAPERFLOW |
| 169 | parts.append(f'<line x1="{LEFT}" y1="{y}" x2="{RIGHT}" y2="{y}" stroke="rgb(242,242,242)" stroke-width="1"/>') |
| 170 | parts.append( |
| 171 | f'<text x="{LEFT - 22}" y="{y + 8}" font-family="Times New Roman" ' |
| 172 | f'font-size="24" font-weight="700" text-anchor="end" fill="{rgb(label_color)}">{name}</text>' |
| 173 | ) |
| 174 | parts.append(f'<circle cx="{x}" cy="{y}" r="9" fill="{rgb(color)}"/>') |
| 175 | parts.append( |
| 176 | f'<text x="{x + 15}" y="{y + 8}" font-family="Times New Roman" ' |
| 177 | f'font-size="22" font-weight="700" fill="{rgb(color)}">{tokens / 1_000_000:.1f}M</text>' |
| 178 | ) |
| 179 | |
| 180 | parts.append("</svg>") |
| 181 | SVG_OUT.write_text("\n".join(parts), encoding="utf-8") |
| 182 | |
| 183 | |
| 184 | def main() -> None: |