@clipen/clipen-cli 0.0.0-stage → 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +79 -2
- package/apps/web/dist/assets/index-D5D2HiB1.js +14 -0
- package/apps/web/dist/assets/index-DIMuOXSu.css +1 -0
- package/apps/web/dist/favicon.svg +1 -0
- package/apps/web/dist/index.html +16 -0
- package/bin/clipen.js +157 -0
- package/clipen +18 -0
- package/install +25 -0
- package/package.json +52 -4
- package/pyproject.toml +28 -0
- package/requirements/asr-runtime.txt +13 -0
- package/requirements/runtime.txt +20 -0
- package/src/clipen/__init__.py +3 -0
- package/src/clipen/analysis/__init__.py +89 -0
- package/src/clipen/analysis/artifacts.py +416 -0
- package/src/clipen/analysis/audio.py +392 -0
- package/src/clipen/analysis/evidence.py +102 -0
- package/src/clipen/analysis/evidence_service.py +751 -0
- package/src/clipen/analysis/image_similarity.py +143 -0
- package/src/clipen/analysis/keyframes.py +171 -0
- package/src/clipen/analysis/models.py +230 -0
- package/src/clipen/analysis/qwen_worker.py +629 -0
- package/src/clipen/analysis/resources.py +21 -0
- package/src/clipen/analysis/runtime.py +64 -0
- package/src/clipen/analysis/service.py +626 -0
- package/src/clipen/analysis/setup.py +935 -0
- package/src/clipen/analysis/setup_cli.py +117 -0
- package/src/clipen/analysis/storage.py +2046 -0
- package/src/clipen/analysis/transcription.py +948 -0
- package/src/clipen/analysis/visual.py +176 -0
- package/src/clipen/annotations/__init__.py +10 -0
- package/src/clipen/annotations/models.py +22 -0
- package/src/clipen/annotations/storage.py +380 -0
- package/src/clipen/annotations/suggestions.py +120 -0
- package/src/clipen/asr_release.py +139 -0
- package/src/clipen/bootstrap.py +967 -0
- package/src/clipen/cli.py +84 -0
- package/src/clipen/controller/__init__.py +17 -0
- package/src/clipen/controller/app.py +1470 -0
- package/src/clipen/controller/server.py +543 -0
- package/src/clipen/domain/__init__.py +30 -0
- package/src/clipen/domain/errors.py +5 -0
- package/src/clipen/domain/media_time.py +117 -0
- package/src/clipen/domain/timeline.py +584 -0
- package/src/clipen/domain/validation.py +15 -0
- package/src/clipen/editing/EDITORIAL_REGRESSIONS.md +38 -0
- package/src/clipen/editing/PROGRAM_FORMAT.md +102 -0
- package/src/clipen/editing/README.md +115 -0
- package/src/clipen/editing/REFACTOR_DESIGN.md +241 -0
- package/src/clipen/editing/REFACTOR_HANDOFF.md +73 -0
- package/src/clipen/editing/__init__.py +15 -0
- package/src/clipen/editing/agent.py +13 -0
- package/src/clipen/editing/agent_models.py +134 -0
- package/src/clipen/editing/agent_repository.py +757 -0
- package/src/clipen/editing/agent_tools.py +532 -0
- package/src/clipen/editing/alignment.py +110 -0
- package/src/clipen/editing/alignment_setup.py +108 -0
- package/src/clipen/editing/alignment_worker.py +22 -0
- package/src/clipen/editing/change_report.py +71 -0
- package/src/clipen/editing/compiler.py +41 -0
- package/src/clipen/editing/component_looks.py +107 -0
- package/src/clipen/editing/component_review.py +78 -0
- package/src/clipen/editing/coordinator.py +374 -0
- package/src/clipen/editing/editorial_review.py +187 -0
- package/src/clipen/editing/evidence_jobs.py +295 -0
- package/src/clipen/editing/history_changes.py +131 -0
- package/src/clipen/editing/music_choices.py +15 -0
- package/src/clipen/editing/production_catalog.py +192 -0
- package/src/clipen/editing/production_limits.py +59 -0
- package/src/clipen/editing/production_media.py +226 -0
- package/src/clipen/editing/production_preview.py +180 -0
- package/src/clipen/editing/production_progress.py +141 -0
- package/src/clipen/editing/production_requirements.py +50 -0
- package/src/clipen/editing/production_tools.py +596 -0
- package/src/clipen/editing/program_audio.py +118 -0
- package/src/clipen/editing/program_direction.py +49 -0
- package/src/clipen/editing/program_story.py +53 -0
- package/src/clipen/editing/program_subtitles.py +134 -0
- package/src/clipen/editing/programme_review.py +73 -0
- package/src/clipen/editing/prompt_history.py +47 -0
- package/src/clipen/editing/recut.py +127 -0
- package/src/clipen/editing/refinement_references.py +188 -0
- package/src/clipen/editing/resolve_export.py +616 -0
- package/src/clipen/editing/resolve_titles.py +234 -0
- package/src/clipen/editing/skill_tools.py +575 -0
- package/src/clipen/editing/source_dialogue.py +82 -0
- package/src/clipen/editing/speech_coverage.py +30 -0
- package/src/clipen/editing/speech_quality.py +6 -0
- package/src/clipen/editing/tool_receipts.py +52 -0
- package/src/clipen/editing/versions.py +161 -0
- package/src/clipen/editing/visual_preview.py +93 -0
- package/src/clipen/editing/workbench.py +74 -0
- package/src/clipen/filesystem.py +25 -0
- package/src/clipen/finishing/README.md +103 -0
- package/src/clipen/finishing/__init__.py +1 -0
- package/src/clipen/finishing/audio.py +149 -0
- package/src/clipen/finishing/catalog.py +181 -0
- package/src/clipen/finishing/models.py +14 -0
- package/src/clipen/finishing/renderer.py +26 -0
- package/src/clipen/mcp_editing/__init__.py +5 -0
- package/src/clipen/mcp_editing/__main__.py +40 -0
- package/src/clipen/mcp_editing/server.py +353 -0
- package/src/clipen/media/__init__.py +50 -0
- package/src/clipen/media/discovery.py +266 -0
- package/src/clipen/media/models.py +360 -0
- package/src/clipen/media/preview.py +147 -0
- package/src/clipen/media/probe.py +446 -0
- package/src/clipen/media/service.py +317 -0
- package/src/clipen/media/storage.py +742 -0
- package/src/clipen/music_vocabulary.py +5 -0
- package/src/clipen/planning/__init__.py +9 -0
- package/src/clipen/planning/models.py +240 -0
- package/src/clipen/power.py +23 -0
- package/src/clipen/projects/__init__.py +26 -0
- package/src/clipen/projects/agent_schema.py +94 -0
- package/src/clipen/projects/annotation_schema.py +40 -0
- package/src/clipen/projects/deletion.py +269 -0
- package/src/clipen/projects/evidence_schema.py +52 -0
- package/src/clipen/projects/finishing_schema.py +34 -0
- package/src/clipen/projects/models.py +192 -0
- package/src/clipen/projects/picker.py +256 -0
- package/src/clipen/projects/preview_schema.py +29 -0
- package/src/clipen/projects/service.py +175 -0
- package/src/clipen/projects/storage.py +1478 -0
- package/src/clipen/projects/timeline_schema.py +32 -0
- package/src/clipen/projects/validation_schema.py +28 -0
- package/src/clipen/provider_registry.py +75 -0
- package/src/clipen/providers/__init__.py +43 -0
- package/src/clipen/providers/account.py +194 -0
- package/src/clipen/providers/claude.py +375 -0
- package/src/clipen/providers/claude_editing.py +111 -0
- package/src/clipen/providers/codex.py +1036 -0
- package/src/clipen/providers/codex_editing.py +91 -0
- package/src/clipen/providers/editing_agent.py +565 -0
- package/src/clipen/providers/errors.py +51 -0
- package/src/clipen/providers/recovery.py +270 -0
- package/src/clipen/py.typed +1 -0
- package/src/clipen/rendering/__init__.py +12 -0
- package/src/clipen/rendering/cover.py +126 -0
- package/src/clipen/rendering/custom_components.py +240 -0
- package/src/clipen/rendering/custom_render.py +197 -0
- package/src/clipen/rendering/fonts/anton-OFL.txt +93 -0
- package/src/clipen/rendering/fonts/bebasneue-OFL.txt +93 -0
- package/src/clipen/rendering/fonts/caveat-OFL.txt +93 -0
- package/src/clipen/rendering/fonts/chenyu-OFL.txt +93 -0
- package/src/clipen/rendering/fonts/delagothicone-OFL.txt +93 -0
- package/src/clipen/rendering/fonts/hachimarupop-OFL.txt +93 -0
- package/src/clipen/rendering/fonts/iansui-OFL.txt +93 -0
- package/src/clipen/rendering/fonts/manifest.json +145 -0
- package/src/clipen/rendering/fonts/playfairdisplay-OFL.txt +93 -0
- package/src/clipen/rendering/fonts/rocknrollone-OFL.txt +93 -0
- package/src/clipen/rendering/fonts/yomogi-OFL.txt +94 -0
- package/src/clipen/rendering/fonts/yuseimagic-OFL.txt +93 -0
- package/src/clipen/rendering/fonts/zenkurenaido-OFL.txt +93 -0
- package/src/clipen/rendering/fonts/zenmarugothic-OFL.txt +93 -0
- package/src/clipen/rendering/production_effects.py +64 -0
- package/src/clipen/rendering/program_components.py +193 -0
- package/src/clipen/rendering/program_creator.py +649 -0
- package/src/clipen/rendering/program_identities.py +255 -0
- package/src/clipen/rendering/program_motion.py +141 -0
- package/src/clipen/rendering/program_studio.py +168 -0
- package/src/clipen/rendering/program_styles.py +235 -0
- package/src/clipen/rendering/program_subtitles.py +52 -0
- package/src/clipen/rendering/renderer.py +708 -0
- package/src/clipen/rendering/storage.py +243 -0
- package/src/clipen/rendering/titles.py +360 -0
- package/src/clipen/skills/__init__.py +4 -0
- package/src/clipen/skills/builtin/SKILL.md +72 -0
- package/src/clipen/skills/builtin/assets/sample-daily-vlog.mp4 +0 -0
- package/src/clipen/skills/builtin/assets/sample-event-recap.mp4 +0 -0
- package/src/clipen/skills/builtin/assets/sample-food-review.mp4 +0 -0
- package/src/clipen/skills/builtin/assets/sample-product-demo.mp4 +0 -0
- package/src/clipen/skills/builtin/assets/sample-product-review.mp4 +0 -0
- package/src/clipen/skills/builtin/assets/sample-product-unboxing.mp4 +0 -0
- package/src/clipen/skills/builtin/assets/sample-shorts-highlight.mp4 +0 -0
- package/src/clipen/skills/builtin/assets/sample-travel-highlight.mp4 +0 -0
- package/src/clipen/skills/builtin/assets/sample-travel-vlog.mp4 +0 -0
- package/src/clipen/skills/builtin/assets/style-cinema.png +0 -0
- package/src/clipen/skills/builtin/assets/style-editorial.png +0 -0
- package/src/clipen/skills/builtin/assets/style-tpl-daily-vlog.png +0 -0
- package/src/clipen/skills/builtin/assets/style-tpl-event-recap.png +0 -0
- package/src/clipen/skills/builtin/assets/style-tpl-food-review.png +0 -0
- package/src/clipen/skills/builtin/assets/style-tpl-product-demo.png +0 -0
- package/src/clipen/skills/builtin/assets/style-tpl-product-review.png +0 -0
- package/src/clipen/skills/builtin/assets/style-tpl-product-unboxing.png +0 -0
- package/src/clipen/skills/builtin/assets/style-tpl-shorts-highlight.png +0 -0
- package/src/clipen/skills/builtin/assets/style-tpl-travel-highlight.png +0 -0
- package/src/clipen/skills/builtin/assets/style-tpl-travel-vlog.png +0 -0
- package/src/clipen/skills/builtin/assets/style-variety.png +0 -0
- package/src/clipen/skills/builtin/components.json +133 -0
- package/src/clipen/skills/builtin/font_sources.json +20 -0
- package/src/clipen/skills/builtin/font_styles.json +329 -0
- package/src/clipen/skills/builtin/manifest.json +32 -0
- package/src/clipen/skills/builtin/presets.json +8 -0
- package/src/clipen/skills/builtin/references/captions.md +14 -0
- package/src/clipen/skills/builtin/references/channel-design.md +37 -0
- package/src/clipen/skills/builtin/references/editing.md +30 -0
- package/src/clipen/skills/builtin/references/font-chenyu-OFL.txt +93 -0
- package/src/clipen/skills/builtin/references/font-iansui-OFL.txt +93 -0
- package/src/clipen/skills/builtin/references/graphics.md +59 -0
- package/src/clipen/skills/builtin/references/review.md +16 -0
- package/src/clipen/skills/builtin/references/sound.md +8 -0
- package/src/clipen/skills/builtin/references/story.md +7 -0
- package/src/clipen/skills/builtin/skills/travel-program/SKILL.md +27 -0
- package/src/clipen/skills/builtin/skills/travel-program/manifest.json +6 -0
- package/src/clipen/skills/builtin/template-skills/clipen-daily-vlog/SKILL.md +33 -0
- package/src/clipen/skills/builtin/template-skills/clipen-daily-vlog/manifest.json +8 -0
- package/src/clipen/skills/builtin/template-skills/clipen-event-recap/SKILL.md +34 -0
- package/src/clipen/skills/builtin/template-skills/clipen-event-recap/manifest.json +8 -0
- package/src/clipen/skills/builtin/template-skills/clipen-food-review/SKILL.md +33 -0
- package/src/clipen/skills/builtin/template-skills/clipen-food-review/manifest.json +8 -0
- package/src/clipen/skills/builtin/template-skills/clipen-product-demo/SKILL.md +35 -0
- package/src/clipen/skills/builtin/template-skills/clipen-product-demo/manifest.json +8 -0
- package/src/clipen/skills/builtin/template-skills/clipen-product-review/SKILL.md +36 -0
- package/src/clipen/skills/builtin/template-skills/clipen-product-review/manifest.json +8 -0
- package/src/clipen/skills/builtin/template-skills/clipen-product-unboxing/SKILL.md +39 -0
- package/src/clipen/skills/builtin/template-skills/clipen-product-unboxing/manifest.json +8 -0
- package/src/clipen/skills/builtin/template-skills/clipen-shorts-highlight/SKILL.md +38 -0
- package/src/clipen/skills/builtin/template-skills/clipen-shorts-highlight/manifest.json +8 -0
- package/src/clipen/skills/builtin/template-skills/clipen-travel-highlight/SKILL.md +34 -0
- package/src/clipen/skills/builtin/template-skills/clipen-travel-highlight/manifest.json +8 -0
- package/src/clipen/skills/builtin/template-skills/clipen-travel-vlog/SKILL.md +37 -0
- package/src/clipen/skills/builtin/template-skills/clipen-travel-vlog/manifest.json +8 -0
- package/src/clipen/skills/builtin/templates.json +284 -0
- package/src/clipen/skills/builtin/visual_styles.json +1074 -0
- package/src/clipen/skills/catalog.py +218 -0
- package/src/clipen/skills/library.py +131 -0
- package/src/clipen/skills/package.py +231 -0
- package/src/clipen/skills/visual_styles.py +44 -0
- package/src/clipen/workspace.py +210 -0
- package/uninstall +25 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"""Original channel packages: measured type, distinct geometry and native motion.
|
|
2
|
+
|
|
3
|
+
An identity is frozen in the text profile, just like its fonts and palette. These
|
|
4
|
+
are procedural overlays used by both the samples and the actual film renderer.
|
|
5
|
+
"""
|
|
6
|
+
import math
|
|
7
|
+
|
|
8
|
+
from .titles import TitleRenderError
|
|
9
|
+
from .program_styles import load_style_font, styled_text_length, draw_style_text, type_outline
|
|
10
|
+
|
|
11
|
+
HERO = {'program_title', 'headline', 'impact', 'chapter', 'burst'}
|
|
12
|
+
IDENTITIES = {'journal', 'city', 'slow', 'night', 'food', 'mission',
|
|
13
|
+
'coffee', 'family', 'outdoor', 'portrait', 'retro', 'tech'}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def identity(profile):
|
|
17
|
+
value = profile.get('presets', {}).get('appearance', {}).get('identity')
|
|
18
|
+
return value if value in IDENTITIES else None
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _lines(value, name, kind):
|
|
22
|
+
if kind != 'program_title':
|
|
23
|
+
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
|
|
28
|
+
return value[:middle], value[middle:]
|
|
29
|
+
return (value,)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def layout(draw, font_path, timeline, item, profile):
|
|
33
|
+
name, kind = identity(profile), profile['component_id']
|
|
34
|
+
hero = kind in HERO
|
|
35
|
+
primary, _, detail = item.text.partition('\n')
|
|
36
|
+
lines = _lines(primary, name, kind)
|
|
37
|
+
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)
|
|
49
|
+
# A real header and footer are reserved in the collision footprint, rather
|
|
50
|
+
# than adding decorative marks outside the validated bounds.
|
|
51
|
+
extra = pad*(6 if name in {'coffee', 'retro', 'tech'} else 4)
|
|
52
|
+
while True:
|
|
53
|
+
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:
|
|
60
|
+
break
|
|
61
|
+
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
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def draw_graphic(draw, font_path, timeline, item, profile, bounds, font, pad, relative_frame=None):
|
|
68
|
+
name, kind = identity(profile), profile['component_id']
|
|
69
|
+
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']
|
|
74
|
+
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)))
|
|
78
|
+
x, y, right, bottom = bounds
|
|
79
|
+
width, height = right-x, bottom-y
|
|
80
|
+
primary, _, detail = item.text.partition('\n')
|
|
81
|
+
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')
|
|
86
|
+
|
|
87
|
+
def color(key, opacity=1):
|
|
88
|
+
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':
|
|
116
|
+
# 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')
|
|
119
|
+
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')
|
|
123
|
+
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':
|
|
132
|
+
# 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':
|
|
140
|
+
# 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':
|
|
146
|
+
# 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')
|
|
150
|
+
for n in range(4):
|
|
151
|
+
rule((right-pad*.7, y+pad*(1+n*.7), right-pad*.3, y+pad*(1+n*.7)), 'secondary')
|
|
152
|
+
label(kicker)
|
|
153
|
+
elif name == 'food':
|
|
154
|
+
# A scalloped menu seal, red/yellow plates and bold reaction lettering.
|
|
155
|
+
pts = []
|
|
156
|
+
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':
|
|
166
|
+
# 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'))
|
|
170
|
+
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)
|
|
174
|
+
# 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':
|
|
178
|
+
# 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':
|
|
189
|
+
# 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'))
|
|
193
|
+
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':
|
|
198
|
+
# Survey plate with topographic contour lines and an expedition rail.
|
|
199
|
+
draw.rectangle((x, y, right, bottom), fill=color('ink', .90))
|
|
200
|
+
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')
|
|
206
|
+
outlined = True
|
|
207
|
+
elif name == 'portrait':
|
|
208
|
+
# 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':
|
|
215
|
+
# 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'
|
|
224
|
+
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'
|
|
232
|
+
|
|
233
|
+
for n, value in enumerate(lines):
|
|
234
|
+
local = min(1., max(0., p*1.5-n*.28))
|
|
235
|
+
if not local:
|
|
236
|
+
continue
|
|
237
|
+
# Each package has a different entrance grammar while the final text
|
|
238
|
+
# 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
|
|
248
|
+
text((tx, ty), value, font, text_fill, outlined)
|
|
249
|
+
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')
|
|
255
|
+
return bounds
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""Original broadcast graphics: bounded layouts and frame-driven entrance motion."""
|
|
2
|
+
import math
|
|
3
|
+
|
|
4
|
+
from .titles import TitleRenderError
|
|
5
|
+
from .program_styles import skin, style_font, load_style_font, styled_text_length, draw_styled_graphic, draw_style_text, type_outline
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Each family owns its composition, rather than stretching the small label style.
|
|
9
|
+
FAMILIES = {
|
|
10
|
+
'program_title': (.125, .80, .29, 24, 8),
|
|
11
|
+
'headline': (.135, .82, .24, 20, 7),
|
|
12
|
+
'impact': (.145, .74, .27, 16, 6),
|
|
13
|
+
'chapter': (.075, .78, .18, 22, 8),
|
|
14
|
+
'burst': (.108, .62, .27, 20, 6),
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def motion_frames(kind, profile=None):
|
|
19
|
+
appearance=(profile or {}).get('presets',{}).get('appearance',{})
|
|
20
|
+
return (appearance.get('hero_entry_frames',FAMILIES[kind][3]),
|
|
21
|
+
appearance.get('hero_exit_frames',FAMILIES[kind][4]))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def layout(draw, font_path, timeline, item, profile):
|
|
25
|
+
if skin(profile) == 'studio':
|
|
26
|
+
from .program_studio import layout as studio_layout
|
|
27
|
+
return studio_layout(draw, font_path, timeline, item, profile)
|
|
28
|
+
scale, max_width, height, _, _ = FAMILIES[profile['component_id']]
|
|
29
|
+
font_path=style_font(font_path,profile)
|
|
30
|
+
scale*=profile['presets'].get('appearance',{}).get('hero_scale',1.)
|
|
31
|
+
w, h = timeline.width, timeline.height
|
|
32
|
+
x, y = round(w*profile['x']), round(h*profile['y'])
|
|
33
|
+
pad = max(8, round(h*.025))
|
|
34
|
+
primary, _, detail = item.text.partition('\n')
|
|
35
|
+
limit = min(w*max_width, w*.945-x)
|
|
36
|
+
size = max(14, round(h*scale))
|
|
37
|
+
minimum = max(14, round(h*scale*.70))
|
|
38
|
+
while True:
|
|
39
|
+
font = load_style_font(font_path, size,profile)
|
|
40
|
+
# Room for outline, shadow, skew and framing, including transient motion.
|
|
41
|
+
width = styled_text_length(primary,font)+pad*4
|
|
42
|
+
if width <= limit or size <= minimum:
|
|
43
|
+
break
|
|
44
|
+
size -= 1
|
|
45
|
+
small = load_style_font(font_path,max(12,round(h*.027)),profile,role='detail')
|
|
46
|
+
width = max(width, styled_text_length(detail,small)+pad*4 if detail else 0, w*.30)
|
|
47
|
+
bottom = y+round(h*height)
|
|
48
|
+
if width > limit or bottom > h*.77:
|
|
49
|
+
raise TitleRenderError('program_component_overflow')
|
|
50
|
+
return (x, y, x+math.ceil(width), bottom), font, pad
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def draw_motion_graphic(draw, font_path, timeline, item, profile, relative_frame=None):
|
|
54
|
+
bounds, font, pad = layout(draw, font_path, timeline, item, profile)
|
|
55
|
+
if skin(profile)!='variety':
|
|
56
|
+
return draw_styled_graphic(draw,font_path,timeline,item,profile,bounds,font,pad,relative_frame)
|
|
57
|
+
kind = profile['component_id']
|
|
58
|
+
entry, exit_frames = motion_frames(kind,profile)
|
|
59
|
+
relative = entry if relative_frame is None else relative_frame
|
|
60
|
+
progress = min(1., max(0., (relative+1)/entry))
|
|
61
|
+
ease = 1-(1-progress)**3
|
|
62
|
+
opacity = min(1., max(0., (item.duration_frames-relative)/exit_frames))
|
|
63
|
+
palette = profile['presets']['palette']
|
|
64
|
+
|
|
65
|
+
def color(name, alpha=1.):
|
|
66
|
+
r, g, b, a = palette[name]
|
|
67
|
+
return r, g, b, round(a*opacity*alpha)
|
|
68
|
+
|
|
69
|
+
x, y, right, bottom = bounds
|
|
70
|
+
width, height = right-x, bottom-y
|
|
71
|
+
stroke = max(2, round(timeline.height*.004))
|
|
72
|
+
primary, _, detail = item.text.partition('\n')
|
|
73
|
+
small = load_style_font(font_path, max(12, round(timeline.height*.027)),profile,role='detail')
|
|
74
|
+
kicker = load_style_font(font_path, max(10, round(timeline.height*.020)),profile,role='detail')
|
|
75
|
+
|
|
76
|
+
def text(position, value, *, fill='paper', selected_font=font, outline=True):
|
|
77
|
+
draw_style_text(draw,position,value,selected_font,color(fill),type_outline(profile,selected_font,stroke*2) if outline else 0,color('ink'))
|
|
78
|
+
# Embolden the glyph itself; CJK collections may expose a light default face.
|
|
79
|
+
if not profile['presets'].get('font_roles'):
|
|
80
|
+
draw_style_text(draw,position,value,selected_font,color(fill),max(1,stroke//2) if selected_font is font else 0,color(fill))
|
|
81
|
+
|
|
82
|
+
if kind == 'program_title':
|
|
83
|
+
# Two framing strokes reveal first; the title rises into the open frame.
|
|
84
|
+
reveal = width*ease
|
|
85
|
+
draw.rectangle((x, y, x+reveal, y+stroke*2), fill=color('accent'))
|
|
86
|
+
draw.rectangle((right-reveal, bottom-stroke, right, bottom), fill=color('secondary'))
|
|
87
|
+
draw.rectangle((x, y+stroke*2, x+stroke, bottom), fill=color('accent', ease))
|
|
88
|
+
draw.rectangle((x+pad, y+pad*.5, x+pad+max(width*.25, timeline.width*.16)*ease, y+pad*2.0), fill=color('accent'))
|
|
89
|
+
draw.text((x+pad*1.2, y+pad*.74), 'ON LOCATION', font=kicker, fill=color('ink'), anchor='lt')
|
|
90
|
+
tx, ty = x+pad*1.4, y+height*.32+(1-ease)*pad
|
|
91
|
+
text((tx+stroke*2, ty+stroke*2), primary, fill='ink')
|
|
92
|
+
text((tx, ty), primary)
|
|
93
|
+
elif kind == 'headline':
|
|
94
|
+
# Word-sized punches arrive left-to-right over an expanding slanted band.
|
|
95
|
+
band_y = y+height*.10
|
|
96
|
+
draw.polygon([(x,band_y+height*.12),(x+width*ease,band_y),
|
|
97
|
+
(x+width*ease-pad, y+height*.76),(x,y+height*.76)],fill=color('accent'))
|
|
98
|
+
cursor=x+pad*1.5
|
|
99
|
+
for n, char in enumerate(primary):
|
|
100
|
+
local=min(1.,max(0.,progress*1.8-n/max(1,len(primary))*.8))
|
|
101
|
+
if local:
|
|
102
|
+
text((cursor,y+height*.19+(1-local)**2*pad),char,fill='ink',outline=False)
|
|
103
|
+
cursor+=draw.textlength(char,font=font)
|
|
104
|
+
elif kind == 'impact':
|
|
105
|
+
# A slam contracts from a displaced shadow into solid outlined type.
|
|
106
|
+
hit = min(1., progress*1.8)
|
|
107
|
+
tx, ty = x+pad*2, y+height*.20
|
|
108
|
+
offset=round((1-hit)*pad*1.5)+stroke*2
|
|
109
|
+
text((tx+offset,ty+offset),primary,fill='secondary')
|
|
110
|
+
text((tx,ty),primary,fill='accent')
|
|
111
|
+
for side in (-1,1):
|
|
112
|
+
edge=x+pad*.8 if side<0 else right-pad*.8
|
|
113
|
+
draw.line((edge,y+height*.2,edge+side*pad*.5*ease,y+height*.05),fill=color('accent'),width=stroke*2)
|
|
114
|
+
draw.line((edge,y+height*.48,edge+side*pad*.5*ease,y+height*.56),fill=color('paper'),width=stroke)
|
|
115
|
+
elif kind == 'chapter':
|
|
116
|
+
# A tab and panel wipe establish a new segment while footage stays visible.
|
|
117
|
+
end=x+width*ease
|
|
118
|
+
draw.polygon([(x,y),(end,y),(end-pad,y+height*.78),(x,y+height*.78)],fill=color('ink'))
|
|
119
|
+
draw.rectangle((x,y,x+pad*.65,y+height*.78),fill=color('secondary'))
|
|
120
|
+
draw.line((x+pad,bottom-stroke,x+width*ease,bottom-stroke),fill=color('accent'),width=stroke*2)
|
|
121
|
+
if progress > .28:
|
|
122
|
+
text((x+pad*1.5,y+height*.16),primary)
|
|
123
|
+
else: # burst: an angular outlined badge with outward growing rays.
|
|
124
|
+
cx,cy=(x+right)/2,y+height*.43
|
|
125
|
+
rx,ry=width*.44*ease,height*.39*ease
|
|
126
|
+
points=[]
|
|
127
|
+
for n in range(20):
|
|
128
|
+
angle=math.tau*n/20
|
|
129
|
+
radius=1. if n%2==0 else .80
|
|
130
|
+
points.append((cx+math.cos(angle)*rx*radius,cy+math.sin(angle)*ry*radius))
|
|
131
|
+
draw.polygon(points,fill=color('ink'),outline=color('accent'),width=stroke*2)
|
|
132
|
+
if progress>.35:
|
|
133
|
+
text((x+pad*2,y+height*.27),primary,fill='accent')
|
|
134
|
+
for angle in (0,math.pi*.20,math.pi*.80,math.pi):
|
|
135
|
+
start=(cx+math.cos(angle)*width*.46,cy+math.sin(angle)*height*.44)
|
|
136
|
+
end=(start[0]+math.cos(angle)*pad*.6*ease,start[1]+math.sin(angle)*pad*.5*ease)
|
|
137
|
+
draw.line((start,end),fill=color('secondary'),width=stroke*2)
|
|
138
|
+
if detail:
|
|
139
|
+
# Secondary line has reserved space; never lies on top of the main title.
|
|
140
|
+
text((x+pad*1.5,bottom-pad*1.9),detail,selected_font=small)
|
|
141
|
+
return bounds
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""Original editorial identity: type lockups, cut-paper tickets and drawn marks.
|
|
2
|
+
|
|
3
|
+
All decoration and motion stays inside the measured component footprint. This is
|
|
4
|
+
procedural artwork, so no remote assets, invented source facts or raster scaling.
|
|
5
|
+
"""
|
|
6
|
+
import math
|
|
7
|
+
|
|
8
|
+
from .titles import TitleRenderError
|
|
9
|
+
from .program_styles import load_style_font, styled_text_length, draw_style_text, type_outline
|
|
10
|
+
|
|
11
|
+
HERO = {'program_title', 'headline', 'impact', 'chapter', 'burst'}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def title_lines(value):
|
|
15
|
+
if '・' in value:
|
|
16
|
+
return tuple(value.split('・', 1))
|
|
17
|
+
if len(value) > 3:
|
|
18
|
+
middle = (len(value)+1)//2
|
|
19
|
+
return value[:middle], value[middle:]
|
|
20
|
+
return (value,)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def layout(draw, font_path, timeline, item, profile):
|
|
24
|
+
kind = profile['component_id']
|
|
25
|
+
hero = kind in HERO
|
|
26
|
+
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'
|
|
30
|
+
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')
|
|
37
|
+
# Reserve a separate column for a rosette; artwork never covers title type.
|
|
38
|
+
ornament = h*.13 if split else pad*2
|
|
39
|
+
while True:
|
|
40
|
+
font = load_style_font(font_path, size, profile)
|
|
41
|
+
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))
|
|
45
|
+
if width <= limit or size <= minimum:
|
|
46
|
+
break
|
|
47
|
+
size -= 1
|
|
48
|
+
height = round(size*len(lines)*1.18+pad*3+(small.size*1.35 if detail else 0))
|
|
49
|
+
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
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def draw_graphic(draw, font_path, timeline, item, profile, bounds, font, pad, relative_frame=None):
|
|
57
|
+
kind = profile['component_id']
|
|
58
|
+
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']
|
|
63
|
+
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')
|
|
75
|
+
|
|
76
|
+
def color(name, opacity=1):
|
|
77
|
+
r,g,b,a = palette[name]
|
|
78
|
+
return r,g,b,round(a*alpha*opacity)
|
|
79
|
+
|
|
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))
|
|
84
|
+
|
|
85
|
+
def rosette(cx, cy, radius, fill='accent'):
|
|
86
|
+
points=[]
|
|
87
|
+
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))
|
|
92
|
+
# 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'))
|
|
97
|
+
|
|
98
|
+
if kind == 'program_title':
|
|
99
|
+
# Open typographic lockup with staggered rows, a registration rail and
|
|
100
|
+
# 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'}:
|
|
127
|
+
# 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')
|
|
137
|
+
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':
|
|
141
|
+
# 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)
|
|
147
|
+
else:
|
|
148
|
+
# 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)
|
|
159
|
+
if detail:
|
|
160
|
+
# 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)
|
|
166
|
+
else:
|
|
167
|
+
text((x+pad*1.3,ty),detail,small,'ink')
|
|
168
|
+
return bounds
|