@clipen/clipen-cli 1.0.0 → 1.0.2

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 (132) hide show
  1. package/README.md +56 -48
  2. package/apps/web/dist/assets/{index-D5D2HiB1.js → index-DPHwA954.js} +1 -1
  3. package/apps/web/dist/index.html +1 -1
  4. package/bin/clipen.js +1 -1
  5. package/package.json +7 -6
  6. package/pyproject.toml +18 -2
  7. package/requirements/dev.txt +2 -0
  8. package/src/clipen/__init__.py +1 -1
  9. package/src/clipen/analysis/__init__.py +7 -7
  10. package/src/clipen/analysis/artifacts.py +4 -10
  11. package/src/clipen/analysis/audio.py +10 -8
  12. package/src/clipen/analysis/evidence_service.py +345 -167
  13. package/src/clipen/analysis/image_similarity.py +5 -14
  14. package/src/clipen/analysis/keyframes.py +5 -17
  15. package/src/clipen/analysis/models.py +5 -7
  16. package/src/clipen/analysis/qwen_worker.py +19 -54
  17. package/src/clipen/analysis/resources.py +2 -1
  18. package/src/clipen/analysis/runtime.py +1 -3
  19. package/src/clipen/analysis/service.py +16 -48
  20. package/src/clipen/analysis/setup.py +11 -25
  21. package/src/clipen/analysis/setup_cli.py +5 -15
  22. package/src/clipen/analysis/storage.py +96 -278
  23. package/src/clipen/analysis/transcription.py +40 -82
  24. package/src/clipen/analysis/visual.py +109 -48
  25. package/src/clipen/annotations/__init__.py +5 -2
  26. package/src/clipen/annotations/models.py +1 -1
  27. package/src/clipen/annotations/storage.py +132 -84
  28. package/src/clipen/annotations/suggestions.py +3 -8
  29. package/src/clipen/asr_release.py +4 -11
  30. package/src/clipen/bootstrap.py +71 -61
  31. package/src/clipen/{planning/models.py → candidates.py} +29 -47
  32. package/src/clipen/cli.py +4 -9
  33. package/src/clipen/controller/app.py +401 -214
  34. package/src/clipen/controller/server.py +28 -38
  35. package/src/clipen/domain/__init__.py +1 -1
  36. package/src/clipen/domain/media_time.py +3 -10
  37. package/src/clipen/domain/timeline.py +45 -47
  38. package/src/clipen/domain/validation.py +0 -1
  39. package/src/clipen/editing/__init__.py +1 -1
  40. package/src/clipen/editing/agent_models.py +4 -11
  41. package/src/clipen/editing/agent_repository.py +393 -172
  42. package/src/clipen/editing/agent_tools.py +180 -99
  43. package/src/clipen/editing/alignment.py +92 -52
  44. package/src/clipen/editing/alignment_setup.py +118 -70
  45. package/src/clipen/editing/alignment_worker.py +11 -9
  46. package/src/clipen/editing/change_report.py +95 -38
  47. package/src/clipen/editing/compiler.py +0 -1
  48. package/src/clipen/editing/component_looks.py +58 -34
  49. package/src/clipen/editing/component_review.py +34 -38
  50. package/src/clipen/editing/coordinator.py +213 -92
  51. package/src/clipen/editing/editorial_review.py +217 -95
  52. package/src/clipen/editing/evidence_jobs.py +457 -200
  53. package/src/clipen/editing/history_changes.py +129 -68
  54. package/src/clipen/editing/music_choices.py +8 -5
  55. package/src/clipen/editing/production_catalog.py +573 -136
  56. package/src/clipen/editing/production_limits.py +43 -17
  57. package/src/clipen/editing/production_media.py +376 -167
  58. package/src/clipen/editing/production_preview.py +322 -129
  59. package/src/clipen/editing/production_progress.py +164 -69
  60. package/src/clipen/editing/production_requirements.py +106 -39
  61. package/src/clipen/editing/production_tools.py +1064 -462
  62. package/src/clipen/editing/program_audio.py +211 -81
  63. package/src/clipen/editing/program_direction.py +59 -25
  64. package/src/clipen/editing/program_story.py +83 -45
  65. package/src/clipen/editing/program_subtitles.py +194 -96
  66. package/src/clipen/editing/programme_review.py +98 -50
  67. package/src/clipen/editing/prompt_history.py +64 -27
  68. package/src/clipen/editing/recut.py +65 -25
  69. package/src/clipen/editing/refinement_references.py +176 -86
  70. package/src/clipen/editing/resolve_export.py +449 -218
  71. package/src/clipen/editing/resolve_titles.py +162 -105
  72. package/src/clipen/editing/skill_tools.py +530 -154
  73. package/src/clipen/editing/source_dialogue.py +177 -67
  74. package/src/clipen/editing/speech_coverage.py +42 -22
  75. package/src/clipen/editing/speech_quality.py +6 -1
  76. package/src/clipen/editing/tool_receipts.py +78 -32
  77. package/src/clipen/editing/versions.py +122 -64
  78. package/src/clipen/editing/visual_preview.py +157 -61
  79. package/src/clipen/editing/workbench.py +104 -42
  80. package/src/clipen/finishing/audio.py +69 -30
  81. package/src/clipen/finishing/catalog.py +176 -93
  82. package/src/clipen/finishing/models.py +1 -1
  83. package/src/clipen/finishing/renderer.py +33 -14
  84. package/src/clipen/mcp_editing/__main__.py +3 -1
  85. package/src/clipen/mcp_editing/server.py +77 -34
  86. package/src/clipen/media/__init__.py +3 -3
  87. package/src/clipen/media/discovery.py +7 -20
  88. package/src/clipen/media/models.py +7 -18
  89. package/src/clipen/media/preview.py +14 -24
  90. package/src/clipen/media/probe.py +16 -44
  91. package/src/clipen/media/service.py +6 -19
  92. package/src/clipen/media/storage.py +33 -81
  93. package/src/clipen/music_vocabulary.py +33 -4
  94. package/src/clipen/power.py +8 -3
  95. package/src/clipen/projects/__init__.py +1 -1
  96. package/src/clipen/projects/deletion.py +19 -32
  97. package/src/clipen/projects/finishing_schema.py +3 -1
  98. package/src/clipen/projects/models.py +2 -5
  99. package/src/clipen/projects/picker.py +13 -37
  100. package/src/clipen/projects/service.py +8 -24
  101. package/src/clipen/projects/storage.py +226 -246
  102. package/src/clipen/provider_registry.py +9 -20
  103. package/src/clipen/providers/account.py +86 -35
  104. package/src/clipen/providers/claude.py +59 -25
  105. package/src/clipen/providers/claude_editing.py +14 -7
  106. package/src/clipen/providers/codex.py +73 -118
  107. package/src/clipen/providers/codex_editing.py +2 -2
  108. package/src/clipen/providers/editing_agent.py +19 -17
  109. package/src/clipen/providers/recovery.py +7 -8
  110. package/src/clipen/rendering/cover.py +18 -5
  111. package/src/clipen/rendering/custom_components.py +167 -79
  112. package/src/clipen/rendering/custom_render.py +62 -41
  113. package/src/clipen/rendering/production_effects.py +77 -45
  114. package/src/clipen/rendering/program_components.py +134 -73
  115. package/src/clipen/rendering/program_creator.py +432 -277
  116. package/src/clipen/rendering/program_identities.py +277 -182
  117. package/src/clipen/rendering/program_motion.py +140 -95
  118. package/src/clipen/rendering/program_studio.py +175 -116
  119. package/src/clipen/rendering/program_styles.py +231 -145
  120. package/src/clipen/rendering/program_subtitles.py +71 -34
  121. package/src/clipen/rendering/renderer.py +150 -121
  122. package/src/clipen/rendering/storage.py +9 -22
  123. package/src/clipen/rendering/titles.py +193 -86
  124. package/src/clipen/skills/__init__.py +1 -0
  125. package/src/clipen/skills/catalog.py +151 -55
  126. package/src/clipen/skills/library.py +13 -7
  127. package/src/clipen/skills/package.py +46 -23
  128. package/src/clipen/skills/visual_styles.py +29 -18
  129. package/src/clipen/workspace.py +15 -44
  130. package/install +0 -25
  131. package/src/clipen/planning/__init__.py +0 -9
  132. package/uninstall +0 -25
@@ -3,166 +3,225 @@
3
3
  All decoration and motion stays inside the measured component footprint. This is
4
4
  procedural artwork, so no remote assets, invented source facts or raster scaling.
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
+ HERO = {"program_title", "headline", "impact", "chapter", "burst"}
12
13
 
13
14
 
14
15
  def title_lines(value):
15
- if '・' in value:
16
- return tuple(value.split('・', 1))
16
+ if "・" in value:
17
+ return tuple(value.split("・", 1))
17
18
  if len(value) > 3:
18
- middle = (len(value)+1)//2
19
+ middle = (len(value) + 1) // 2
19
20
  return value[:middle], value[middle:]
20
21
  return (value,)
21
22
 
22
23
 
23
24
  def layout(draw, font_path, timeline, item, profile):
24
- kind = profile['component_id']
25
+ kind = profile["component_id"]
25
26
  hero = kind in HERO
26
27
  w, h = timeline.width, timeline.height
27
- x, y = round(w*profile['x']), round(h*profile['y'])
28
- primary, _, detail = item.text.partition('\n')
29
- split = kind == 'program_title'
28
+ x, y = round(w * profile["x"]), round(h * profile["y"])
29
+ primary, _, detail = item.text.partition("\n")
30
+ split = kind == "program_title"
30
31
  lines = title_lines(primary) if split else (primary,)
31
- scale = .108 if split else .091 if hero else .061 if kind == 'reaction' else .040
32
- pad = max(8, round(h*.022))
33
- limit = min(w*(.83 if hero else .58), w*.945-x)
34
- minimum = max(14, round(h*scale*.70))
35
- size = max(14, round(h*scale))
36
- small = load_style_font(font_path, max(12, round(h*.024)), profile, role='detail')
32
+ scale = 0.108 if split else 0.091 if hero else 0.061 if kind == "reaction" else 0.040
33
+ pad = max(8, round(h * 0.022))
34
+ limit = min(w * (0.83 if hero else 0.58), w * 0.945 - x)
35
+ minimum = max(14, round(h * scale * 0.70))
36
+ size = max(14, round(h * scale))
37
+ small = load_style_font(font_path, max(12, round(h * 0.024)), profile, role="detail")
37
38
  # Reserve a separate column for a rosette; artwork never covers title type.
38
- ornament = h*.13 if split else pad*2
39
+ ornament = h * 0.13 if split else pad * 2
39
40
  while True:
40
41
  font = load_style_font(font_path, size, profile)
41
42
  text_width = max(styled_text_length(line, font) for line in lines)
42
- width = max(text_width + pad*4 + ornament,
43
- styled_text_length(detail, small)+pad*4 if detail else 0,
44
- w*(.39 if split else .19 if hero else .13))
43
+ width = max(
44
+ text_width + pad * 4 + ornament,
45
+ styled_text_length(detail, small) + pad * 4 if detail else 0,
46
+ w * (0.39 if split else 0.19 if hero else 0.13),
47
+ )
45
48
  if width <= limit or size <= minimum:
46
49
  break
47
50
  size -= 1
48
- height = round(size*len(lines)*1.18+pad*3+(small.size*1.35 if detail else 0))
51
+ height = round(size * len(lines) * 1.18 + pad * 3 + (small.size * 1.35 if detail else 0))
49
52
  if split:
50
- height += round(pad*.5)
51
- if width > limit or y+height > h*.77:
52
- raise TitleRenderError('program_component_overflow')
53
- return (x,y,x+math.ceil(width),y+height), font, pad
53
+ height += round(pad * 0.5)
54
+ if width > limit or y + height > h * 0.77:
55
+ raise TitleRenderError("program_component_overflow")
56
+ return (x, y, x + math.ceil(width), y + height), font, pad
54
57
 
55
58
 
56
59
  def draw_graphic(draw, font_path, timeline, item, profile, bounds, font, pad, relative_frame=None):
57
- kind = profile['component_id']
60
+ kind = profile["component_id"]
58
61
  hero = kind in HERO
59
- appearance = profile['presets']['appearance']
60
- motion = profile['presets']['motion']
61
- entry = appearance['hero_entry_frames'] if hero else motion['entry_frames']
62
- end = appearance['hero_exit_frames'] if hero else motion['exit_frames']
62
+ appearance = profile["presets"]["appearance"]
63
+ motion = profile["presets"]["motion"]
64
+ entry = appearance["hero_entry_frames"] if hero else motion["entry_frames"]
65
+ end = appearance["hero_exit_frames"] if hero else motion["exit_frames"]
63
66
  relative = entry if relative_frame is None else relative_frame
64
- p = min(1., max(0., (relative+1)/entry))
65
- exit_progress = min(1., max(0., (item.duration_frames-relative)/end))
66
- alpha = min(1., p*3, exit_progress)
67
- ease = 1-(1-p)**3
68
- x,y,right,bottom = bounds
69
- width,height = right-x,bottom-y
70
- primary,_,detail = item.text.partition('\n')
71
- palette = profile['presets']['palette']
72
- stroke = max(1, round(timeline.height*.0025))
73
- small = load_style_font(font_path,max(12,round(timeline.height*.024)),profile,role='detail')
74
- micro = load_style_font(font_path,max(9,round(timeline.height*.017)),profile,role='detail')
67
+ p = min(1.0, max(0.0, (relative + 1) / entry))
68
+ exit_progress = min(1.0, max(0.0, (item.duration_frames - relative) / end))
69
+ alpha = min(1.0, p * 3, exit_progress)
70
+ ease = 1 - (1 - p) ** 3
71
+ x, y, right, bottom = bounds
72
+ width, height = right - x, bottom - y
73
+ primary, _, detail = item.text.partition("\n")
74
+ palette = profile["presets"]["palette"]
75
+ stroke = max(1, round(timeline.height * 0.0025))
76
+ small = load_style_font(font_path, max(12, round(timeline.height * 0.024)), profile, role="detail")
77
+ micro = load_style_font(font_path, max(9, round(timeline.height * 0.017)), profile, role="detail")
75
78
 
76
79
  def color(name, opacity=1):
77
- r,g,b,a = palette[name]
78
- return r,g,b,round(a*alpha*opacity)
80
+ r, g, b, a = palette[name]
81
+ return r, g, b, round(a * alpha * opacity)
79
82
 
80
- def text(pos, value, selected=font, fill='paper', outline=False):
81
- draw_style_text(draw,pos,value,selected,color(fill),type_outline(profile,selected,stroke*3) if outline else 0,color('ink'))
82
- if selected is font and not profile['presets'].get('font_roles'):
83
- draw_style_text(draw,pos,value,selected,color(fill),max(1,stroke),color(fill))
83
+ def text(pos, value, selected=font, fill="paper", outline=False):
84
+ draw_style_text(
85
+ draw,
86
+ pos,
87
+ value,
88
+ selected,
89
+ color(fill),
90
+ type_outline(profile, selected, stroke * 3) if outline else 0,
91
+ color("ink"),
92
+ )
93
+ if selected is font and not profile["presets"].get("font_roles"):
94
+ draw_style_text(draw, pos, value, selected, color(fill), max(1, stroke), color(fill))
84
95
 
85
- def rosette(cx, cy, radius, fill='accent'):
86
- points=[]
96
+ def rosette(cx, cy, radius, fill="accent"):
97
+ points = []
87
98
  for n in range(32):
88
- angle=math.tau*n/32-.18*(1-ease)
89
- r=radius*(1 if n%2==0 else .76)*(.65+.35*ease)
90
- points.append((cx+math.cos(angle)*r,cy+math.sin(angle)*r))
91
- draw.polygon(points,fill=color(fill))
99
+ angle = math.tau * n / 32 - 0.18 * (1 - ease)
100
+ r = radius * (1 if n % 2 == 0 else 0.76) * (0.65 + 0.35 * ease)
101
+ points.append((cx + math.cos(angle) * r, cy + math.sin(angle) * r))
102
+ draw.polygon(points, fill=color(fill))
92
103
  # Original four-point cutout inside the print rosette.
93
- r=radius*.40
94
- draw.polygon([(cx,cy-r),(cx+r*.22,cy-r*.22),(cx+r,cy),
95
- (cx+r*.22,cy+r*.22),(cx,cy+r),(cx-r*.22,cy+r*.22),
96
- (cx-r,cy),(cx-r*.22,cy-r*.22)], fill=color('paper'))
104
+ r = radius * 0.40
105
+ draw.polygon(
106
+ [
107
+ (cx, cy - r),
108
+ (cx + r * 0.22, cy - r * 0.22),
109
+ (cx + r, cy),
110
+ (cx + r * 0.22, cy + r * 0.22),
111
+ (cx, cy + r),
112
+ (cx - r * 0.22, cy + r * 0.22),
113
+ (cx - r, cy),
114
+ (cx - r * 0.22, cy - r * 0.22),
115
+ ],
116
+ fill=color("paper"),
117
+ )
97
118
 
98
- if kind == 'program_title':
119
+ if kind == "program_title":
99
120
  # Open typographic lockup with staggered rows, a registration rail and
100
121
  # a separate decorative seal. No enclosing title rectangle.
101
- rail=x+pad*.25
102
- draw.line((rail,y+pad,rail,y+height*ease-pad),fill=color('paper'),width=stroke)
103
- for dy in (pad,height*.49,height-pad):
104
- draw.line((rail-stroke*2,y+dy,rail+stroke*2,y+dy),fill=color('paper'),width=stroke)
105
- badge_x=x+pad*1.2
106
- badge_w=micro.getlength('FIELD NOTES')+pad*1.8
107
- draw.rounded_rectangle((badge_x,y+pad*.2,badge_x+badge_w,y+pad*1.35),radius=pad*.55,fill=color('accent'))
108
- text((badge_x+pad*.9,y+pad*.40),'FIELD NOTES',micro,'ink')
109
- lines=title_lines(primary)
110
- ty=y+pad*1.9
111
- for n,line in enumerate(lines):
112
- phase=min(1.,max(0.,p*1.65-n*.35))
113
- if not phase:continue
114
- shift=(1-phase)**3*pad
115
- tx=x+pad*(1.2+n*.7)+shift
116
- yy=ty+n*font.size*1.18
117
- shadow=stroke if profile['presets'].get('font_roles') else stroke*2
118
- text((tx+shadow,yy+shadow),line,fill='ink',outline=True)
119
- text((tx,yy),line,outline=True)
120
- r=min(timeline.height*.055,height*.19)
121
- rosette(right-r-pad*.6,y+pad*2+r,r)
122
- underline_y=ty+font.size*len(lines)*1.18+pad*.12
123
- length=max(styled_text_length(line,font) for line in lines)
124
- draw.line([(x+pad*1.4,underline_y),(x+pad+length*ease,underline_y-pad*.3),
125
- (x+pad+length*ease,underline_y+stroke*2)],fill=color('accent'),width=stroke*3)
126
- elif kind in {'impact','reaction','burst'}:
122
+ rail = x + pad * 0.25
123
+ draw.line((rail, y + pad, rail, y + height * ease - pad), fill=color("paper"), width=stroke)
124
+ for dy in (pad, height * 0.49, height - pad):
125
+ draw.line((rail - stroke * 2, y + dy, rail + stroke * 2, y + dy), fill=color("paper"), width=stroke)
126
+ badge_x = x + pad * 1.2
127
+ badge_w = micro.getlength("FIELD NOTES") + pad * 1.8
128
+ draw.rounded_rectangle(
129
+ (badge_x, y + pad * 0.2, badge_x + badge_w, y + pad * 1.35), radius=pad * 0.55, fill=color("accent")
130
+ )
131
+ text((badge_x + pad * 0.9, y + pad * 0.40), "FIELD NOTES", micro, "ink")
132
+ lines = title_lines(primary)
133
+ ty = y + pad * 1.9
134
+ for n, line in enumerate(lines):
135
+ phase = min(1.0, max(0.0, p * 1.65 - n * 0.35))
136
+ if not phase:
137
+ continue
138
+ shift = (1 - phase) ** 3 * pad
139
+ tx = x + pad * (1.2 + n * 0.7) + shift
140
+ yy = ty + n * font.size * 1.18
141
+ shadow = stroke if profile["presets"].get("font_roles") else stroke * 2
142
+ text((tx + shadow, yy + shadow), line, fill="ink", outline=True)
143
+ text((tx, yy), line, outline=True)
144
+ r = min(timeline.height * 0.055, height * 0.19)
145
+ rosette(right - r - pad * 0.6, y + pad * 2 + r, r)
146
+ underline_y = ty + font.size * len(lines) * 1.18 + pad * 0.12
147
+ length = max(styled_text_length(line, font) for line in lines)
148
+ draw.line(
149
+ [
150
+ (x + pad * 1.4, underline_y),
151
+ (x + pad + length * ease, underline_y - pad * 0.3),
152
+ (x + pad + length * ease, underline_y + stroke * 2),
153
+ ],
154
+ fill=color("accent"),
155
+ width=stroke * 3,
156
+ )
157
+ elif kind in {"impact", "reaction", "burst"}:
127
158
  # A cut-paper sticker with offset ink edge and an asymmetrical silhouette.
128
- top=y+pad*.7
129
- points=[(x+pad,top),(right-pad*2,y+pad*.2),(right-pad*.3,top+pad),
130
- (right-pad,bottom-pad*.65),(x+pad*.5,bottom-pad*.3),(x+pad*.15,top+pad)]
131
- draw.polygon([(a+stroke*2,b+stroke*2) for a,b in points],fill=color('ink'))
132
- draw.polygon(points,fill=color('accent'),outline=color('paper'),width=stroke*2)
133
- if kind=='burst':
134
- rosette(right-pad*1.25,y+pad*1.25,pad*.8,'secondary')
135
- if p>.18:
136
- text((x+pad*1.3,y+pad*1.3+(1-ease)*pad*.5),primary,fill='ink')
159
+ top = y + pad * 0.7
160
+ points = [
161
+ (x + pad, top),
162
+ (right - pad * 2, y + pad * 0.2),
163
+ (right - pad * 0.3, top + pad),
164
+ (right - pad, bottom - pad * 0.65),
165
+ (x + pad * 0.5, bottom - pad * 0.3),
166
+ (x + pad * 0.15, top + pad),
167
+ ]
168
+ draw.polygon([(a + stroke * 2, b + stroke * 2) for a, b in points], fill=color("ink"))
169
+ draw.polygon(points, fill=color("accent"), outline=color("paper"), width=stroke * 2)
170
+ if kind == "burst":
171
+ rosette(right - pad * 1.25, y + pad * 1.25, pad * 0.8, "secondary")
172
+ if p > 0.18:
173
+ text((x + pad * 1.3, y + pad * 1.3 + (1 - ease) * pad * 0.5), primary, fill="ink")
137
174
  for n in range(3):
138
- xx=x+pad*(1.2+n*.5)
139
- draw.line((xx,y+pad*.5,xx+pad*.2,y+pad*.1),fill=color('paper'),width=stroke)
140
- elif kind == 'chapter':
175
+ xx = x + pad * (1.2 + n * 0.5)
176
+ draw.line((xx, y + pad * 0.5, xx + pad * 0.2, y + pad * 0.1), fill=color("paper"), width=stroke)
177
+ elif kind == "chapter":
141
178
  # A coloured tab and open ruled heading, without a full panel.
142
- tab_width=styled_text_length('CHAPTER',micro)+pad*1.2
143
- draw.rounded_rectangle((x+pad*.3,y+pad*.2,x+pad*.3+tab_width,y+pad*1.35),radius=pad*.2,fill=color('accent'))
144
- text((x+pad*.6,y+pad*.35),'CHAPTER',micro,'ink')
145
- text((x+pad,y+pad*1.9+(1-ease)*pad),primary,outline=True)
146
- draw.line((x+pad,bottom-pad*.5,x+pad+(width-pad*2)*ease,bottom-pad*.5),fill=color('paper'),width=stroke*2)
179
+ tab_width = styled_text_length("CHAPTER", micro) + pad * 1.2
180
+ draw.rounded_rectangle(
181
+ (x + pad * 0.3, y + pad * 0.2, x + pad * 0.3 + tab_width, y + pad * 1.35),
182
+ radius=pad * 0.2,
183
+ fill=color("accent"),
184
+ )
185
+ text((x + pad * 0.6, y + pad * 0.35), "CHAPTER", micro, "ink")
186
+ text((x + pad, y + pad * 1.9 + (1 - ease) * pad), primary, outline=True)
187
+ draw.line(
188
+ (x + pad, bottom - pad * 0.5, x + pad + (width - pad * 2) * ease, bottom - pad * 0.5),
189
+ fill=color("paper"),
190
+ width=stroke * 2,
191
+ )
147
192
  else:
148
193
  # Ticket shape: clipped corners, perforation line, coloured folded tab.
149
- notch=pad*.4
150
- bx,by,br,bb=x+pad*.15,y+pad*.2,right-pad*.2,bottom-pad*.2
151
- draw.polygon([(bx+notch,by),(br-notch,by),(br,by+notch),
152
- (br,bb-notch),(br-notch,bb),(bx+notch,bb),(bx,bb-notch),(bx,by+notch)],
153
- fill=color('paper'))
154
- draw.polygon([(bx,by),(bx+pad*.9,by),(bx,by+pad*.9)],fill=color('accent'))
155
- for yy in range(round(by+pad*.5),round(bb-pad*.3),max(3,stroke*4)):
156
- draw.line((br-pad*.65,yy,br-pad*.65,yy+stroke),fill=color('secondary'),width=stroke)
157
- text((bx+pad,y+pad*.85+(1-ease)*pad*.2),primary,fill='ink')
158
- draw.line((bx+pad,bb-pad*.35,bx+pad+(width-pad*3)*ease,bb-pad*.35),fill=color('accent'),width=stroke*2)
194
+ notch = pad * 0.4
195
+ bx, by, br, bb = x + pad * 0.15, y + pad * 0.2, right - pad * 0.2, bottom - pad * 0.2
196
+ draw.polygon(
197
+ [
198
+ (bx + notch, by),
199
+ (br - notch, by),
200
+ (br, by + notch),
201
+ (br, bb - notch),
202
+ (br - notch, bb),
203
+ (bx + notch, bb),
204
+ (bx, bb - notch),
205
+ (bx, by + notch),
206
+ ],
207
+ fill=color("paper"),
208
+ )
209
+ draw.polygon([(bx, by), (bx + pad * 0.9, by), (bx, by + pad * 0.9)], fill=color("accent"))
210
+ for yy in range(round(by + pad * 0.5), round(bb - pad * 0.3), max(3, stroke * 4)):
211
+ draw.line((br - pad * 0.65, yy, br - pad * 0.65, yy + stroke), fill=color("secondary"), width=stroke)
212
+ text((bx + pad, y + pad * 0.85 + (1 - ease) * pad * 0.2), primary, fill="ink")
213
+ draw.line(
214
+ (bx + pad, bb - pad * 0.35, bx + pad + (width - pad * 3) * ease, bb - pad * 0.35),
215
+ fill=color("accent"),
216
+ width=stroke * 2,
217
+ )
159
218
  if detail:
160
219
  # Secondary line is reserved below the primary composition.
161
- ty=bottom-small.size-pad*.7
162
- if kind in {'program_title','chapter'}:
163
- tw=styled_text_length(detail,small)
164
- draw.rectangle((x+pad,ty-pad*.25,x+pad*2+tw,bottom-pad*.35),fill=color('ink'))
165
- text((x+pad*1.5,ty),detail,small)
220
+ ty = bottom - small.size - pad * 0.7
221
+ if kind in {"program_title", "chapter"}:
222
+ tw = styled_text_length(detail, small)
223
+ draw.rectangle((x + pad, ty - pad * 0.25, x + pad * 2 + tw, bottom - pad * 0.35), fill=color("ink"))
224
+ text((x + pad * 1.5, ty), detail, small)
166
225
  else:
167
- text((x+pad*1.3,ty),detail,small,'ink')
226
+ text((x + pad * 1.3, ty), detail, small, "ink")
168
227
  return bounds