@clipen/clipen-cli 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +60 -50
  2. package/package.json +7 -4
  3. package/pyproject.toml +18 -2
  4. package/requirements/dev.txt +2 -0
  5. package/src/clipen/__init__.py +1 -1
  6. package/src/clipen/analysis/__init__.py +7 -7
  7. package/src/clipen/analysis/artifacts.py +4 -10
  8. package/src/clipen/analysis/audio.py +10 -8
  9. package/src/clipen/analysis/evidence_service.py +345 -167
  10. package/src/clipen/analysis/image_similarity.py +5 -14
  11. package/src/clipen/analysis/keyframes.py +5 -17
  12. package/src/clipen/analysis/models.py +5 -7
  13. package/src/clipen/analysis/qwen_worker.py +19 -54
  14. package/src/clipen/analysis/resources.py +2 -1
  15. package/src/clipen/analysis/runtime.py +1 -3
  16. package/src/clipen/analysis/service.py +16 -48
  17. package/src/clipen/analysis/setup.py +11 -25
  18. package/src/clipen/analysis/setup_cli.py +5 -15
  19. package/src/clipen/analysis/storage.py +96 -278
  20. package/src/clipen/analysis/transcription.py +40 -82
  21. package/src/clipen/analysis/visual.py +109 -48
  22. package/src/clipen/annotations/__init__.py +5 -2
  23. package/src/clipen/annotations/models.py +1 -1
  24. package/src/clipen/annotations/storage.py +132 -84
  25. package/src/clipen/annotations/suggestions.py +3 -8
  26. package/src/clipen/asr_release.py +4 -11
  27. package/src/clipen/bootstrap.py +65 -54
  28. package/src/clipen/{planning/models.py → candidates.py} +29 -47
  29. package/src/clipen/cli.py +2 -2
  30. package/src/clipen/controller/app.py +401 -214
  31. package/src/clipen/controller/server.py +28 -38
  32. package/src/clipen/domain/__init__.py +1 -1
  33. package/src/clipen/domain/media_time.py +3 -10
  34. package/src/clipen/domain/timeline.py +45 -47
  35. package/src/clipen/domain/validation.py +0 -1
  36. package/src/clipen/editing/__init__.py +1 -1
  37. package/src/clipen/editing/agent_models.py +4 -11
  38. package/src/clipen/editing/agent_repository.py +391 -170
  39. package/src/clipen/editing/agent_tools.py +180 -99
  40. package/src/clipen/editing/alignment.py +92 -52
  41. package/src/clipen/editing/alignment_setup.py +118 -70
  42. package/src/clipen/editing/alignment_worker.py +11 -9
  43. package/src/clipen/editing/change_report.py +95 -38
  44. package/src/clipen/editing/compiler.py +0 -1
  45. package/src/clipen/editing/component_looks.py +58 -34
  46. package/src/clipen/editing/component_review.py +34 -38
  47. package/src/clipen/editing/coordinator.py +213 -90
  48. package/src/clipen/editing/editorial_review.py +217 -95
  49. package/src/clipen/editing/evidence_jobs.py +457 -200
  50. package/src/clipen/editing/history_changes.py +129 -68
  51. package/src/clipen/editing/music_choices.py +8 -5
  52. package/src/clipen/editing/production_catalog.py +573 -136
  53. package/src/clipen/editing/production_limits.py +43 -17
  54. package/src/clipen/editing/production_media.py +376 -167
  55. package/src/clipen/editing/production_preview.py +322 -129
  56. package/src/clipen/editing/production_progress.py +164 -69
  57. package/src/clipen/editing/production_requirements.py +106 -39
  58. package/src/clipen/editing/production_tools.py +1064 -462
  59. package/src/clipen/editing/program_audio.py +211 -81
  60. package/src/clipen/editing/program_direction.py +59 -25
  61. package/src/clipen/editing/program_story.py +83 -45
  62. package/src/clipen/editing/program_subtitles.py +194 -96
  63. package/src/clipen/editing/programme_review.py +98 -50
  64. package/src/clipen/editing/prompt_history.py +64 -27
  65. package/src/clipen/editing/recut.py +65 -25
  66. package/src/clipen/editing/refinement_references.py +176 -86
  67. package/src/clipen/editing/resolve_export.py +449 -218
  68. package/src/clipen/editing/resolve_titles.py +162 -105
  69. package/src/clipen/editing/skill_tools.py +530 -154
  70. package/src/clipen/editing/source_dialogue.py +177 -67
  71. package/src/clipen/editing/speech_coverage.py +42 -22
  72. package/src/clipen/editing/speech_quality.py +6 -1
  73. package/src/clipen/editing/tool_receipts.py +78 -32
  74. package/src/clipen/editing/versions.py +122 -64
  75. package/src/clipen/editing/visual_preview.py +157 -61
  76. package/src/clipen/editing/workbench.py +104 -42
  77. package/src/clipen/finishing/audio.py +69 -30
  78. package/src/clipen/finishing/catalog.py +176 -93
  79. package/src/clipen/finishing/models.py +1 -1
  80. package/src/clipen/finishing/renderer.py +33 -14
  81. package/src/clipen/mcp_editing/__main__.py +3 -1
  82. package/src/clipen/mcp_editing/server.py +77 -34
  83. package/src/clipen/media/__init__.py +3 -3
  84. package/src/clipen/media/discovery.py +7 -20
  85. package/src/clipen/media/models.py +7 -18
  86. package/src/clipen/media/preview.py +14 -24
  87. package/src/clipen/media/probe.py +16 -44
  88. package/src/clipen/media/service.py +6 -19
  89. package/src/clipen/media/storage.py +33 -81
  90. package/src/clipen/music_vocabulary.py +33 -4
  91. package/src/clipen/power.py +8 -3
  92. package/src/clipen/projects/__init__.py +1 -1
  93. package/src/clipen/projects/deletion.py +19 -32
  94. package/src/clipen/projects/finishing_schema.py +3 -1
  95. package/src/clipen/projects/models.py +2 -5
  96. package/src/clipen/projects/picker.py +13 -37
  97. package/src/clipen/projects/service.py +8 -24
  98. package/src/clipen/projects/storage.py +226 -246
  99. package/src/clipen/provider_registry.py +4 -2
  100. package/src/clipen/providers/account.py +86 -35
  101. package/src/clipen/providers/claude.py +59 -25
  102. package/src/clipen/providers/claude_editing.py +14 -7
  103. package/src/clipen/providers/codex.py +73 -118
  104. package/src/clipen/providers/codex_editing.py +2 -2
  105. package/src/clipen/providers/editing_agent.py +19 -17
  106. package/src/clipen/providers/recovery.py +7 -8
  107. package/src/clipen/rendering/cover.py +18 -5
  108. package/src/clipen/rendering/custom_components.py +167 -79
  109. package/src/clipen/rendering/custom_render.py +62 -41
  110. package/src/clipen/rendering/production_effects.py +77 -45
  111. package/src/clipen/rendering/program_components.py +134 -73
  112. package/src/clipen/rendering/program_creator.py +432 -277
  113. package/src/clipen/rendering/program_identities.py +277 -182
  114. package/src/clipen/rendering/program_motion.py +140 -95
  115. package/src/clipen/rendering/program_studio.py +175 -116
  116. package/src/clipen/rendering/program_styles.py +231 -145
  117. package/src/clipen/rendering/program_subtitles.py +71 -34
  118. package/src/clipen/rendering/renderer.py +150 -121
  119. package/src/clipen/rendering/storage.py +9 -22
  120. package/src/clipen/rendering/titles.py +193 -86
  121. package/src/clipen/skills/__init__.py +1 -0
  122. package/src/clipen/skills/catalog.py +151 -55
  123. package/src/clipen/skills/library.py +13 -7
  124. package/src/clipen/skills/package.py +46 -23
  125. package/src/clipen/skills/visual_styles.py +29 -18
  126. package/src/clipen/workspace.py +15 -44
  127. package/src/clipen/planning/__init__.py +0 -9
@@ -3,253 +3,348 @@
3
3
  An identity is frozen in the text profile, just like its fonts and palette. These
4
4
  are procedural overlays used by both the samples and the actual film renderer.
5
5
  """
6
+
6
7
  import math
7
8
 
9
+ from .program_styles import draw_style_text, load_style_font, styled_text_length, type_outline
8
10
  from .titles import TitleRenderError
9
- from .program_styles import load_style_font, styled_text_length, draw_style_text, type_outline
10
11
 
11
- HERO = {'program_title', 'headline', 'impact', 'chapter', 'burst'}
12
- IDENTITIES = {'journal', 'city', 'slow', 'night', 'food', 'mission',
13
- 'coffee', 'family', 'outdoor', 'portrait', 'retro', 'tech'}
12
+ HERO = {"program_title", "headline", "impact", "chapter", "burst"}
13
+ IDENTITIES = {
14
+ "journal",
15
+ "city",
16
+ "slow",
17
+ "night",
18
+ "food",
19
+ "mission",
20
+ "coffee",
21
+ "family",
22
+ "outdoor",
23
+ "portrait",
24
+ "retro",
25
+ "tech",
26
+ }
14
27
 
15
28
 
16
29
  def identity(profile):
17
- value = profile.get('presets', {}).get('appearance', {}).get('identity')
30
+ value = profile.get("presets", {}).get("appearance", {}).get("identity")
18
31
  return value if value in IDENTITIES else None
19
32
 
20
33
 
21
34
  def _lines(value, name, kind):
22
- if kind != 'program_title':
35
+ if kind != "program_title":
23
36
  return (value,)
24
- if '・' in value:
25
- return tuple(value.split('・', 1))
26
- if name in {'journal', 'city', 'food', 'family', 'retro'} and len(value) > 5:
27
- middle = (len(value)+1)//2
37
+ if "・" in value:
38
+ return tuple(value.split("・", 1))
39
+ if name in {"journal", "city", "food", "family", "retro"} and len(value) > 5:
40
+ middle = (len(value) + 1) // 2
28
41
  return value[:middle], value[middle:]
29
42
  return (value,)
30
43
 
31
44
 
32
45
  def layout(draw, font_path, timeline, item, profile):
33
- name, kind = identity(profile), profile['component_id']
46
+ name, kind = identity(profile), profile["component_id"]
34
47
  hero = kind in HERO
35
- primary, _, detail = item.text.partition('\n')
48
+ primary, _, detail = item.text.partition("\n")
36
49
  lines = _lines(primary, name, kind)
37
50
  h, w = timeline.height, timeline.width
38
- x, y = round(w*profile['x']), round(h*profile['y'])
39
- pad = max(7, round(h*.021))
40
- scale = (.13 if name in {'city', 'food', 'mission'} else
41
- .105 if name in {'journal', 'night', 'retro'} else .09) if hero else .041
42
- if kind in {'impact', 'burst', 'reaction'}:
43
- scale = .14 if hero else .067
44
- size = max(12, round(h*scale))
45
- minimum = max(12, round(size*.58))
46
- small = load_style_font(font_path, max(10, round(h*.025)), profile, role='detail')
47
- micro = load_style_font(font_path, max(8, round(h*.019)), profile, role='detail')
48
- limit = min(w*(.83 if hero else .58), w*.945-x)
51
+ x, y = round(w * profile["x"]), round(h * profile["y"])
52
+ pad = max(7, round(h * 0.021))
53
+ scale = (
54
+ (0.13 if name in {"city", "food", "mission"} else 0.105 if name in {"journal", "night", "retro"} else 0.09)
55
+ if hero
56
+ else 0.041
57
+ )
58
+ if kind in {"impact", "burst", "reaction"}:
59
+ scale = 0.14 if hero else 0.067
60
+ size = max(12, round(h * scale))
61
+ minimum = max(12, round(size * 0.58))
62
+ small = load_style_font(font_path, max(10, round(h * 0.025)), profile, role="detail")
63
+ micro = load_style_font(font_path, max(8, round(h * 0.019)), profile, role="detail")
64
+ limit = min(w * (0.83 if hero else 0.58), w * 0.945 - x)
49
65
  # A real header and footer are reserved in the collision footprint, rather
50
66
  # than adding decorative marks outside the validated bounds.
51
- extra = pad*(6 if name in {'coffee', 'retro', 'tech'} else 4)
67
+ extra = pad * (6 if name in {"coffee", "retro", "tech"} else 4)
52
68
  while True:
53
69
  font = load_style_font(font_path, size, profile)
54
- width = max(max(styled_text_length(line, font) for line in lines)+extra,
55
- styled_text_length(detail, small)+pad*4 if detail else 0,
56
- styled_text_length(profile.get('eyebrow') or 'FIELD EXPEDITION', micro)+pad*7,
57
- pad*12 if hero else pad*8)
58
- height = pad*4 + size*len(lines)*1.18 + (small.size*1.5 if detail else 0)
59
- if (width <= limit and y+height <= h*.77) or size <= minimum:
70
+ width = max(
71
+ max(styled_text_length(line, font) for line in lines) + extra,
72
+ styled_text_length(detail, small) + pad * 4 if detail else 0,
73
+ styled_text_length(profile.get("eyebrow") or "FIELD EXPEDITION", micro) + pad * 7,
74
+ pad * 12 if hero else pad * 8,
75
+ )
76
+ height = pad * 4 + size * len(lines) * 1.18 + (small.size * 1.5 if detail else 0)
77
+ if (width <= limit and y + height <= h * 0.77) or size <= minimum:
60
78
  break
61
79
  size -= 1
62
- if width > limit or y+height > h*.77:
63
- raise TitleRenderError('program_component_overflow')
64
- return (x, y, x+math.ceil(width), y+math.ceil(height)), font, pad
80
+ if width > limit or y + height > h * 0.77:
81
+ raise TitleRenderError("program_component_overflow")
82
+ return (x, y, x + math.ceil(width), y + math.ceil(height)), font, pad
65
83
 
66
84
 
67
85
  def draw_graphic(draw, font_path, timeline, item, profile, bounds, font, pad, relative_frame=None):
68
- name, kind = identity(profile), profile['component_id']
86
+ name, kind = identity(profile), profile["component_id"]
69
87
  hero = kind in HERO
70
- appearance = profile['presets']['appearance']
71
- motion = profile['presets']['motion']
72
- entry = appearance.get('hero_entry_frames', 20) if hero else motion['entry_frames']
73
- exit_frames = appearance.get('hero_exit_frames', 8) if hero else motion['exit_frames']
88
+ appearance = profile["presets"]["appearance"]
89
+ motion = profile["presets"]["motion"]
90
+ entry = appearance.get("hero_entry_frames", 20) if hero else motion["entry_frames"]
91
+ exit_frames = appearance.get("hero_exit_frames", 8) if hero else motion["exit_frames"]
74
92
  relative = entry if relative_frame is None else relative_frame
75
- p = min(1., max(0., (relative+1)/max(1, entry)))
76
- ease = 1-(1-p)**3
77
- alpha = min(1., p*4, max(0., (item.duration_frames-relative)/max(1, exit_frames)))
93
+ p = min(1.0, max(0.0, (relative + 1) / max(1, entry)))
94
+ ease = 1 - (1 - p) ** 3
95
+ alpha = min(1.0, p * 4, max(0.0, (item.duration_frames - relative) / max(1, exit_frames)))
78
96
  x, y, right, bottom = bounds
79
- width, height = right-x, bottom-y
80
- primary, _, detail = item.text.partition('\n')
97
+ width, height = right - x, bottom - y
98
+ primary, _, detail = item.text.partition("\n")
81
99
  lines = _lines(primary, name, kind)
82
- palette = profile['presets']['palette']
83
- stroke = max(1, round(timeline.height*.003))
84
- small = load_style_font(font_path, max(10, round(timeline.height*.025)), profile, role='detail')
85
- micro = load_style_font(font_path, max(8, round(timeline.height*.019)), profile, role='detail')
100
+ palette = profile["presets"]["palette"]
101
+ stroke = max(1, round(timeline.height * 0.003))
102
+ small = load_style_font(font_path, max(10, round(timeline.height * 0.025)), profile, role="detail")
103
+ micro = load_style_font(font_path, max(8, round(timeline.height * 0.019)), profile, role="detail")
86
104
 
87
105
  def color(key, opacity=1):
88
106
  r, g, b, a = palette[key]
89
- return r, g, b, round(a*alpha*opacity)
90
-
91
- def text(at, value, selected=font, fill='ink', outline=False):
92
- draw_style_text(draw, at, value, selected, color(fill), type_outline(profile, selected, stroke*2) if outline else 0, color('ink'))
93
-
94
- def rule(points, fill='accent', weight=1):
95
- draw.line(points, fill=color(fill), width=max(1, stroke*weight))
96
-
97
- def label(value, tx=None, ty=None, fill='accent'):
98
- text((x+pad if tx is None else tx, y+pad*.65 if ty is None else ty), value, micro, fill)
99
-
100
- text_x, text_y, text_fill, outlined = x+pad*2, y+pad*2, 'paper', False
101
- kicker = profile.get('eyebrow') or {
102
- 'program_title': 'ON THE SHOW', 'chapter': 'NEXT CHAPTER',
103
- 'headline': 'THE QUESTION', 'impact': 'HIGHLIGHT', 'burst': 'REACTION',
104
- 'reaction': 'REACTION', 'location': 'ON LOCATION', 'person': 'IN FRAME',
105
- 'fact': 'FIELD NOTES', 'pointer': 'LOOK CLOSER', 'circle': 'DETAIL',
106
- }[kind]
107
- if kind == 'program_title' and not profile.get('eyebrow'):
108
- kicker = {'journal': 'FIELD JOURNAL', 'city': 'CITY / EXPLAINED',
109
- 'slow': 'A VISUAL JOURNAL', 'night': 'NIGHT WALK',
110
- 'food': 'ON THE MENU', 'mission': 'MISSION',
111
- 'coffee': 'COFFEE NOTES', 'family': 'LITTLE MOMENTS',
112
- 'outdoor': 'FIELD EXPEDITION', 'portrait': 'PORTRAIT',
113
- 'retro': 'TRAVEL CINEMA', 'tech': 'FIELD TEST'}[name]
114
-
115
- if name == 'journal':
107
+ return r, g, b, round(a * alpha * opacity)
108
+
109
+ def text(at, value, selected=font, fill="ink", outline=False):
110
+ draw_style_text(
111
+ draw,
112
+ at,
113
+ value,
114
+ selected,
115
+ color(fill),
116
+ type_outline(profile, selected, stroke * 2) if outline else 0,
117
+ color("ink"),
118
+ )
119
+
120
+ def rule(points, fill="accent", weight=1):
121
+ draw.line(points, fill=color(fill), width=max(1, stroke * weight))
122
+
123
+ def label(value, tx=None, ty=None, fill="accent"):
124
+ text((x + pad if tx is None else tx, y + pad * 0.65 if ty is None else ty), value, micro, fill)
125
+
126
+ text_x, text_y, text_fill, outlined = x + pad * 2, y + pad * 2, "paper", False
127
+ kicker = (
128
+ profile.get("eyebrow")
129
+ or {
130
+ "program_title": "ON THE SHOW",
131
+ "chapter": "NEXT CHAPTER",
132
+ "headline": "THE QUESTION",
133
+ "impact": "HIGHLIGHT",
134
+ "burst": "REACTION",
135
+ "reaction": "REACTION",
136
+ "location": "ON LOCATION",
137
+ "person": "IN FRAME",
138
+ "fact": "FIELD NOTES",
139
+ "pointer": "LOOK CLOSER",
140
+ "circle": "DETAIL",
141
+ }[kind]
142
+ )
143
+ if kind == "program_title" and not profile.get("eyebrow"):
144
+ kicker = {
145
+ "journal": "FIELD JOURNAL",
146
+ "city": "CITY / EXPLAINED",
147
+ "slow": "A VISUAL JOURNAL",
148
+ "night": "NIGHT WALK",
149
+ "food": "ON THE MENU",
150
+ "mission": "MISSION",
151
+ "coffee": "COFFEE NOTES",
152
+ "family": "LITTLE MOMENTS",
153
+ "outdoor": "FIELD EXPEDITION",
154
+ "portrait": "PORTRAIT",
155
+ "retro": "TRAVEL CINEMA",
156
+ "tech": "FIELD TEST",
157
+ }[name]
158
+
159
+ if name == "journal":
116
160
  # An open notebook margin, graphite handwriting and an uneven marker.
117
- text_fill = 'ink'
118
- rule((x+pad*.4, y+pad, x+pad*.4, bottom-pad), 'accent')
161
+ text_fill = "ink"
162
+ rule((x + pad * 0.4, y + pad, x + pad * 0.4, bottom - pad), "accent")
119
163
  for n in range(3):
120
- cy = y+pad*(1+n*.7)
121
- draw.ellipse((x+pad*.1, cy, x+pad*.7, cy+pad*.6), outline=color('paper'), width=stroke)
122
- label(kicker, fill='ink')
164
+ cy = y + pad * (1 + n * 0.7)
165
+ draw.ellipse((x + pad * 0.1, cy, x + pad * 0.7, cy + pad * 0.6), outline=color("paper"), width=stroke)
166
+ label(kicker, fill="ink")
123
167
  for n, value in enumerate(lines):
124
- yy = y+pad*2+n*font.size*1.18
125
- draw.rectangle((x+pad*1.6, yy-pad*.2,
126
- x+pad*2.4+styled_text_length(value, font), yy+font.size+pad*.2), fill=color('paper', .96))
127
- length = min(width-pad*3, styled_text_length(lines[-1], font))
128
- yy = y+pad*2+font.size*len(lines)*1.18
129
- rule([(x+pad*2, yy), (x+pad*2+length*ease*.6, yy-pad*.25),
130
- (x+pad*2+length*ease, yy+pad*.1)], 'accent', 3)
131
- elif name == 'city':
168
+ yy = y + pad * 2 + n * font.size * 1.18
169
+ draw.rectangle(
170
+ (
171
+ x + pad * 1.6,
172
+ yy - pad * 0.2,
173
+ x + pad * 2.4 + styled_text_length(value, font),
174
+ yy + font.size + pad * 0.2,
175
+ ),
176
+ fill=color("paper", 0.96),
177
+ )
178
+ length = min(width - pad * 3, styled_text_length(lines[-1], font))
179
+ yy = y + pad * 2 + font.size * len(lines) * 1.18
180
+ rule(
181
+ [
182
+ (x + pad * 2, yy),
183
+ (x + pad * 2 + length * ease * 0.6, yy - pad * 0.25),
184
+ (x + pad * 2 + length * ease, yy + pad * 0.1),
185
+ ],
186
+ "accent",
187
+ 3,
188
+ )
189
+ elif name == "city":
132
190
  # Printed editorial column, boxed kicker and staggered typographic rows.
133
- draw.rectangle((x, y, right, bottom), fill=color('paper'))
134
- draw.rectangle((x, y, x+pad*.7, bottom), fill=color('accent'))
135
- draw.rectangle((x+pad*2, y+pad*.6, right-pad*2, y+pad*1.6), fill=color('ink'))
136
- label(kicker, x+pad*2.4, y+pad*.68, 'paper')
137
- rule((right-pad*1.3, y+pad*2, right-pad*1.3, bottom-pad), 'ink')
138
- text_fill = 'ink'
139
- elif name == 'slow':
191
+ draw.rectangle((x, y, right, bottom), fill=color("paper"))
192
+ draw.rectangle((x, y, x + pad * 0.7, bottom), fill=color("accent"))
193
+ draw.rectangle((x + pad * 2, y + pad * 0.6, right - pad * 2, y + pad * 1.6), fill=color("ink"))
194
+ label(kicker, x + pad * 2.4, y + pad * 0.68, "paper")
195
+ rule((right - pad * 1.3, y + pad * 2, right - pad * 1.3, bottom - pad), "ink")
196
+ text_fill = "ink"
197
+ elif name == "slow":
140
198
  # Small serif lockup and a single expanding hairline: no box.
141
- draw.rectangle((x, y, right, bottom), fill=color('ink', .35))
142
- text_x = x+pad
143
- label(kicker, fill='paper')
144
- rule((x+pad, bottom-pad*.55, x+pad+(width-pad*2)*ease, bottom-pad*.55), 'paper')
145
- elif name == 'night':
199
+ draw.rectangle((x, y, right, bottom), fill=color("ink", 0.35))
200
+ text_x = x + pad
201
+ label(kicker, fill="paper")
202
+ rule((x + pad, bottom - pad * 0.55, x + pad + (width - pad * 2) * ease, bottom - pad * 0.55), "paper")
203
+ elif name == "night":
146
204
  # Offset neon frame, cyan glyph edge and vertical index ticks.
147
- draw.rectangle((x, y, right, bottom), fill=color('ink', .78))
148
- rule((x+stroke, bottom-pad, x+stroke, y+stroke, x+stroke+(width-stroke*2)*ease, y+stroke), 'accent', 2)
149
- rule((x+pad, bottom, right, bottom, right, bottom-height*ease), 'secondary')
205
+ draw.rectangle((x, y, right, bottom), fill=color("ink", 0.78))
206
+ rule(
207
+ (x + stroke, bottom - pad, x + stroke, y + stroke, x + stroke + (width - stroke * 2) * ease, y + stroke),
208
+ "accent",
209
+ 2,
210
+ )
211
+ rule((x + pad, bottom, right, bottom, right, bottom - height * ease), "secondary")
150
212
  for n in range(4):
151
- rule((right-pad*.7, y+pad*(1+n*.7), right-pad*.3, y+pad*(1+n*.7)), 'secondary')
213
+ rule((right - pad * 0.7, y + pad * (1 + n * 0.7), right - pad * 0.3, y + pad * (1 + n * 0.7)), "secondary")
152
214
  label(kicker)
153
- elif name == 'food':
215
+ elif name == "food":
154
216
  # A scalloped menu seal, red/yellow plates and bold reaction lettering.
155
217
  pts = []
156
218
  for n in range(40):
157
- angle = math.tau*n/40
158
- radius = 1 if n % 2 == 0 else .94
159
- pts.append((x+width/2+math.cos(angle)*(width/2-stroke)*radius,
160
- y+height/2+math.sin(angle)*(height/2-stroke)*radius))
161
- draw.polygon(pts, fill=color('accent'), outline=color('paper'), width=stroke*2)
162
- draw.rounded_rectangle((x+pad*1.3, y+pad*.4, right-pad*1.3, y+pad*1.5), radius=pad*.5, fill=color('ink'))
163
- label(kicker, x+pad*2, y+pad*.55, 'secondary')
164
- text_fill, outlined = 'paper', True
165
- elif name == 'mission':
219
+ angle = math.tau * n / 40
220
+ radius = 1 if n % 2 == 0 else 0.94
221
+ pts.append(
222
+ (
223
+ x + width / 2 + math.cos(angle) * (width / 2 - stroke) * radius,
224
+ y + height / 2 + math.sin(angle) * (height / 2 - stroke) * radius,
225
+ )
226
+ )
227
+ draw.polygon(pts, fill=color("accent"), outline=color("paper"), width=stroke * 2)
228
+ draw.rounded_rectangle(
229
+ (x + pad * 1.3, y + pad * 0.4, right - pad * 1.3, y + pad * 1.5), radius=pad * 0.5, fill=color("ink")
230
+ )
231
+ label(kicker, x + pad * 2, y + pad * 0.55, "secondary")
232
+ text_fill, outlined = "paper", True
233
+ elif name == "mission":
166
234
  # A clipped, industrial mission placard with diagonal hazard marks.
167
- cut = pad*1.2
168
- draw.polygon([(x, y), (right-cut, y), (right, y+cut),
169
- (right, bottom), (x+cut, bottom), (x, bottom-cut)], fill=color('ink'))
235
+ cut = pad * 1.2
236
+ draw.polygon(
237
+ [(x, y), (right - cut, y), (right, y + cut), (right, bottom), (x + cut, bottom), (x, bottom - cut)],
238
+ fill=color("ink"),
239
+ )
170
240
  for n in range(5):
171
- xx = x+pad*(1+n*.7)
172
- rule((xx, y+pad*.35, xx+pad*.4, y+pad*.9), 'accent', 2)
173
- rule((x+pad, bottom-pad*.6, x+pad+(width-pad*2)*ease, bottom-pad*.6), 'accent', 3)
241
+ xx = x + pad * (1 + n * 0.7)
242
+ rule((xx, y + pad * 0.35, xx + pad * 0.4, y + pad * 0.9), "accent", 2)
243
+ rule((x + pad, bottom - pad * 0.6, x + pad + (width - pad * 2) * ease, bottom - pad * 0.6), "accent", 3)
174
244
  # No fabricated timers, scores or progress counters in the overlay.
175
- label(kicker, x+pad*5, y+pad*.4, 'secondary')
176
- text_fill = 'accent'
177
- elif name == 'coffee':
245
+ label(kicker, x + pad * 5, y + pad * 0.4, "secondary")
246
+ text_fill = "accent"
247
+ elif name == "coffee":
178
248
  # A letterpress cafe docket: serif text, receipt edge, fine menu rules.
179
- draw.rectangle((x, y, right, bottom), fill=color('paper'))
180
- for n in range(max(1, round(width/pad))):
181
- xx = x+n*pad
182
- draw.polygon([(xx, bottom), (min(right, xx+pad*.5), bottom-pad*.4),
183
- (min(right, xx+pad), bottom)], fill=color('ink'))
184
- rule((x+pad, y+pad*1.5, right-pad, y+pad*1.5), 'ink')
185
- label(kicker, fill='ink')
186
- text_x, text_fill = x+pad*2, 'ink'
187
- draw.arc((right-pad*2, y+pad*.35, right-pad, y+pad*1.25), 0, 320, fill=color('accent'), width=stroke)
188
- elif name == 'family':
249
+ draw.rectangle((x, y, right, bottom), fill=color("paper"))
250
+ for n in range(max(1, round(width / pad))):
251
+ xx = x + n * pad
252
+ draw.polygon(
253
+ [(xx, bottom), (min(right, xx + pad * 0.5), bottom - pad * 0.4), (min(right, xx + pad), bottom)],
254
+ fill=color("ink"),
255
+ )
256
+ rule((x + pad, y + pad * 1.5, right - pad, y + pad * 1.5), "ink")
257
+ label(kicker, fill="ink")
258
+ text_x, text_fill = x + pad * 2, "ink"
259
+ draw.arc(
260
+ (right - pad * 2, y + pad * 0.35, right - pad, y + pad * 1.25), 0, 320, fill=color("accent"), width=stroke
261
+ )
262
+ elif name == "family":
189
263
  # A rounded speech bubble and a hand-drawn sun, distinct from a ticket.
190
- draw.rounded_rectangle((x, y, right, bottom-pad*.5), radius=pad*2, fill=color('paper'))
191
- draw.polygon([(x+pad*2, bottom-pad), (x+pad*1.5, bottom),
192
- (x+pad*4, bottom-pad)], fill=color('paper'))
264
+ draw.rounded_rectangle((x, y, right, bottom - pad * 0.5), radius=pad * 2, fill=color("paper"))
265
+ draw.polygon(
266
+ [(x + pad * 2, bottom - pad), (x + pad * 1.5, bottom), (x + pad * 4, bottom - pad)], fill=color("paper")
267
+ )
193
268
  label(kicker)
194
- text_fill = 'ink'
195
- cx, cy = right-pad*1.5, y+pad
196
- draw.ellipse((cx-pad*.4, cy-pad*.4, cx+pad*.4, cy+pad*.4), fill=color('accent'))
197
- elif name == 'outdoor':
269
+ text_fill = "ink"
270
+ cx, cy = right - pad * 1.5, y + pad
271
+ draw.ellipse((cx - pad * 0.4, cy - pad * 0.4, cx + pad * 0.4, cy + pad * 0.4), fill=color("accent"))
272
+ elif name == "outdoor":
198
273
  # Survey plate with topographic contour lines and an expedition rail.
199
- draw.rectangle((x, y, right, bottom), fill=color('ink', .90))
274
+ draw.rectangle((x, y, right, bottom), fill=color("ink", 0.90))
200
275
  for n in range(4):
201
- yy = y+pad*(.35+n*.3)
202
- rule([(x+pad, yy), (x+width*.35, yy+pad*.2),
203
- (x+width*.7, yy-pad*.1), (right-pad, yy+pad*.3)], 'secondary')
204
- rule((x+pad*.5, y+pad*2, x+pad*.5, bottom-pad), 'accent', 2)
205
- label(kicker, x+pad*2, y+pad*.65, 'accent')
276
+ yy = y + pad * (0.35 + n * 0.3)
277
+ rule(
278
+ [
279
+ (x + pad, yy),
280
+ (x + width * 0.35, yy + pad * 0.2),
281
+ (x + width * 0.7, yy - pad * 0.1),
282
+ (right - pad, yy + pad * 0.3),
283
+ ],
284
+ "secondary",
285
+ )
286
+ rule((x + pad * 0.5, y + pad * 2, x + pad * 0.5, bottom - pad), "accent", 2)
287
+ label(kicker, x + pad * 2, y + pad * 0.65, "accent")
206
288
  outlined = True
207
- elif name == 'portrait':
289
+ elif name == "portrait":
208
290
  # Documentary pull quote, asymmetrical red rule and quiet attribution.
209
- draw.rectangle((x, y, right, bottom), fill=color('ink', .65))
210
- rule((x+stroke*2, y, x+stroke*2, bottom), 'accent', 3)
211
- text((x+pad, y+pad*.1), '“', font, 'accent')
212
- label(kicker, x+pad*4, y+pad*.65, 'paper')
213
- text_x = x+pad*2
214
- elif name == 'retro':
291
+ draw.rectangle((x, y, right, bottom), fill=color("ink", 0.65))
292
+ rule((x + stroke * 2, y, x + stroke * 2, bottom), "accent", 3)
293
+ text((x + pad, y + pad * 0.1), "“", font, "accent")
294
+ label(kicker, x + pad * 4, y + pad * 0.65, "paper")
295
+ text_x = x + pad * 2
296
+ elif name == "retro":
215
297
  # Railway ticket with punch holes, double border and a perforated stub.
216
- draw.rectangle((x, y, right, bottom), fill=color('paper'))
217
- draw.rectangle((x+stroke*3, y+stroke*3, right-stroke*3, bottom-stroke*3), outline=color('ink'), width=stroke)
218
- for yy in range(round(y+pad*.5), round(bottom-pad*.5), max(3, stroke*4)):
219
- rule((right-pad*2, yy, right-pad*2, yy+stroke), 'accent')
220
- for cy in (y+pad, bottom-pad):
221
- draw.ellipse((x+pad*.6, cy-pad*.2, x+pad, cy+pad*.2), fill=color('ink'))
222
- label(kicker, x+pad*2, y+pad*.65, 'accent')
223
- text_fill = 'ink'
298
+ draw.rectangle((x, y, right, bottom), fill=color("paper"))
299
+ draw.rectangle(
300
+ (x + stroke * 3, y + stroke * 3, right - stroke * 3, bottom - stroke * 3),
301
+ outline=color("ink"),
302
+ width=stroke,
303
+ )
304
+ for yy in range(round(y + pad * 0.5), round(bottom - pad * 0.5), max(3, stroke * 4)):
305
+ rule((right - pad * 2, yy, right - pad * 2, yy + stroke), "accent")
306
+ for cy in (y + pad, bottom - pad):
307
+ draw.ellipse((x + pad * 0.6, cy - pad * 0.2, x + pad, cy + pad * 0.2), fill=color("ink"))
308
+ label(kicker, x + pad * 2, y + pad * 0.65, "accent")
309
+ text_fill = "ink"
224
310
  else: # tech: no diagonal comic banner, only a measured spec interface.
225
- draw.rounded_rectangle((x, y, right, bottom), radius=pad*.6, fill=color('ink', .96), outline=color('secondary'), width=stroke)
226
- draw.rectangle((x+pad, y+pad*.6, x+pad*1.5, y+pad*1.1), fill=color('accent'))
227
- label(kicker, x+pad*2, y+pad*.55, 'accent')
228
- rule((x+pad, y+pad*1.6, right-pad, y+pad*1.6), 'secondary')
229
- for xx in (x+pad, right-pad):
230
- rule((xx, bottom-pad*1.5, xx, bottom-pad*.5), 'accent')
231
- text_x, text_fill = x+pad*2, 'paper'
311
+ draw.rounded_rectangle(
312
+ (x, y, right, bottom), radius=pad * 0.6, fill=color("ink", 0.96), outline=color("secondary"), width=stroke
313
+ )
314
+ draw.rectangle((x + pad, y + pad * 0.6, x + pad * 1.5, y + pad * 1.1), fill=color("accent"))
315
+ label(kicker, x + pad * 2, y + pad * 0.55, "accent")
316
+ rule((x + pad, y + pad * 1.6, right - pad, y + pad * 1.6), "secondary")
317
+ for xx in (x + pad, right - pad):
318
+ rule((xx, bottom - pad * 1.5, xx, bottom - pad * 0.5), "accent")
319
+ text_x, text_fill = x + pad * 2, "paper"
232
320
 
233
321
  for n, value in enumerate(lines):
234
- local = min(1., max(0., p*1.5-n*.28))
322
+ local = min(1.0, max(0.0, p * 1.5 - n * 0.28))
235
323
  if not local:
236
324
  continue
237
325
  # Each package has a different entrance grammar while the final text
238
326
  # and all transient strokes remain inside the measured footprint.
239
- offset = (1-local)**3*pad
240
- tx = text_x+offset if name in {'city', 'mission', 'tech'} else text_x
241
- ty = text_y+n*font.size*1.18+(offset if name in {'journal', 'slow', 'portrait', 'family'} else 0)
242
- if name == 'city' and n:
243
- tx += pad*.5
244
- if name == 'night':
245
- text((tx+stroke, ty+stroke), value, font, 'secondary')
246
- if name in {'food', 'mission'} and kind in {'impact', 'burst', 'reaction'}:
247
- tx += (1-ease)*pad
327
+ offset = (1 - local) ** 3 * pad
328
+ tx = text_x + offset if name in {"city", "mission", "tech"} else text_x
329
+ ty = text_y + n * font.size * 1.18 + (offset if name in {"journal", "slow", "portrait", "family"} else 0)
330
+ if name == "city" and n:
331
+ tx += pad * 0.5
332
+ if name == "night":
333
+ text((tx + stroke, ty + stroke), value, font, "secondary")
334
+ if name in {"food", "mission"} and kind in {"impact", "burst", "reaction"}:
335
+ tx += (1 - ease) * pad
248
336
  text((tx, ty), value, font, text_fill, outlined)
249
337
  if detail:
250
- fill = 'ink' if name in {'journal', 'city', 'coffee', 'family', 'retro'} else 'paper'
251
- if name == 'journal':
252
- draw.rectangle((x+pad*1.6, bottom-pad-small.size-pad*.2,
253
- x+pad*2.4+styled_text_length(detail, small), bottom-pad*.6), fill=color('paper'))
254
- text((x+pad*2, bottom-pad-small.size), detail, small, fill, name=='slow')
338
+ fill = "ink" if name in {"journal", "city", "coffee", "family", "retro"} else "paper"
339
+ if name == "journal":
340
+ draw.rectangle(
341
+ (
342
+ x + pad * 1.6,
343
+ bottom - pad - small.size - pad * 0.2,
344
+ x + pad * 2.4 + styled_text_length(detail, small),
345
+ bottom - pad * 0.6,
346
+ ),
347
+ fill=color("paper"),
348
+ )
349
+ text((x + pad * 2, bottom - pad - small.size), detail, small, fill, name == "slow")
255
350
  return bounds