Files
OrbitTv/design/channels/build-batch7-blocks.py
T
pauljdandClaude Opus 5.5 34a8e3862f
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 2m9s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m49s
0.109.0: Advent on Orbit (fixed door slots, holds, door idents), built and replayed, not installed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-04 21:12:56 +00:00

171 lines
9.8 KiB
Python

#!/usr/bin/env python3
"""Batch 7 idents, previews for Paul's review (4 November 2026): Advent on Orbit's shared door (Doors 1 to 24), its Door 25,
and After Dark: The Naughty List.
The 3D is blender/build_block_ident.py (advent, advent25, naughty). This lays the 2D on top the way Batches 3 and 6 do,
reusing Batch 3's helpers and checks unchanged. In the app, the door number comes from the broadcast date and the film from
the confirmed booking; these previews show Door 12 with How the Grinch Stole Christmas, and Door 25 with The Muppet
Christmas Carol, as samples. Nothing here is in the app until Paul approves it.
build-batch7-blocks.py <blender-blocks folder> [advent|advent25|naughty] ...
"""
from pathlib import Path
import importlib.util, json, sys
from PIL import Image, ImageDraw, ImageFilter
HERE = Path(__file__).resolve().parent
spec = importlib.util.spec_from_file_location('batch3', HERE / 'build-batch3-blocks.py')
b3 = importlib.util.module_from_spec(spec)
spec.loader.exec_module(b3)
riot, kf, ease_out, ease_io, glow = b3.riot, b3.kf, b3.ease_out, b3.ease_io, b3.glow
text_layer, place, scaled, font, chrome = b3.text_layer, b3.place, b3.scaled, b3.font, b3.chrome
W, H, LENGTH, MOVE, FPS = b3.W, b3.H, b3.LENGTH, b3.MOVE, b3.FPS
GOLD, NAVY, BLOOD = (242, 193, 78), (14, 33, 71), (178, 8, 18)
BLOCKS = {
'advent': dict(title='Advent on Orbit, Doors 1 to 24', folder='advent-blocks/door', channel='orbit-premiere', sample=('12', 'HOW THE GRINCH STOLE CHRISTMAS')),
'advent25': dict(title='Advent on Orbit, Door 25', folder='advent-blocks/door-25', channel='orbit-premiere', sample=('25', 'THE MUPPET CHRISTMAS CAROL')),
'naughty': dict(title='After Dark: The Naughty List', folder='orbit-after-dark-blocks/naughty-list', channel='orbit-after-dark'),
# The clips the app plays: the door's number, the film and (for Doors 1 to 24) the strap are the app's, drawn from the booking.
'advent_app': dict(title='Advent door, app clip', folder='advent-blocks/door-app', channel='orbit-premiere', scene='advent', app=True),
'advent25_app': dict(title='Advent Door 25, app clip', folder='advent-blocks/door-25-app', channel='orbit-premiere', scene='advent25', app=True),
}
def wrapped(words, face, colour, width, spacing=2):
"""Title words in as few lines as fit [width], each its own layer, centred together."""
lines, line = [], ''
for word in words.split():
trial = (line + ' ' + word).strip()
if line and text_layer(trial, face, colour, spacing).width > width: lines.append(line); line = word
else: line = trial
lines.append(line)
layers = [text_layer(l, face, colour, spacing) for l in lines]
gap = 8
out = Image.new('RGBA', (max(l.width for l in layers), sum(l.height for l in layers) + gap * (len(layers) - 1)))
y = 0
for l in layers:
out.alpha_composite(l, ((out.width - l.width) // 2, y)); y += l.height + gap
return out
class Block(b3.Block):
def __init__(self, key, frames):
self.key, self.cfg, self.frames, self.cache = key, BLOCKS[key], Path(frames) / BLOCKS[key].get('scene', key), {}
self.points = json.loads((self.frames / 'points.json').read_text())
def door(self, pts):
"""Where the door is on screen: Door 25's two leaves taken together."""
pts = pts if 'door' in pts else self.points[str(MOVE)]
d = dict(pts['door'])
if 'door2' in pts:
d2 = pts['door2']
d = dict(left=min(d['left'], d2['left']), right=max(d['right'], d2['right']), top=min(d['top'], d2['top']), bottom=max(d['bottom'], d2['bottom']))
return d
def draw_advent(self, canvas, pts, t, number='12', title='HOW THE GRINCH STOLE CHRISTMAS', big=False):
d = self.door(pts)
cx, cy, w, h = (d['left'] + d['right']) / 2, (d['top'] + d['bottom']) / 2, d['right'] - d['left'], d['bottom'] - d['top']
# The number on the closed door, from the broadcast date in the app. It glows as the door is chosen, then goes as it opens.
a = kf(t, [(.6, 0), (1.0, 1), (1.75, 1), (1.95, 0)], ease_io)
if a > 0 and not big:
face = font('anton-regular.ttf', max(20, int(h * .5)))
num = text_layer(number, face, GOLD + (255,), 2)
lit = kf(t, [(1.1, 0), (1.6, 1)], ease_io)
place(canvas, glow(num, 10, lit), cx - num.width / 2, cy - num.height / 2, a)
place(canvas, num, cx - num.width / 2, cy - num.height / 2, a)
# Inside the opened door: the film, from the confirmed booking.
reveal = kf(t, [(2.75, 0), (3.2, 1)], ease_io)
if reveal > 0:
final = self.door(self.points[str(MOVE)])
fw, fh = final['right'] - final['left'], final['bottom'] - final['top']
fcx, fcy = (final['left'] + final['right']) / 2, (final['top'] + final['bottom']) / 2
if big:
greeting = self.cache.get('greet') or self.cache.setdefault('greet', wrapped('MERRY CHRISTMAS FROM ORBIT', font('barlow-semibold.ttf', 30), (120, 20, 24, 255), fw * .8, 4))
place(canvas, greeting, fcx - greeting.width / 2, final['top'] + fh * .14, reveal)
film = None if not title else self.cache.get(('film', title)) or self.cache.setdefault(('film', title), wrapped(title, font('anton-regular.ttf', 50 if big else 54), NAVY + (255,), fw * .8, 2))
if film is not None: place(canvas, film, fcx - film.width / 2, fcy - film.height / 2 + (fh * .1 if big else 0), reveal)
# The strap: Advent on Orbit, and the door's number.
band = kf(t, [(2.3, 0), (2.8, 1)], ease_io)
if band > 0:
bar = Image.new('RGBA', (W, 92), (6, 14, 36, 230))
line = self.cache.get(('strap', number)) or self.cache.setdefault(('strap', number), text_layer(f'ADVENT ON ORBIT · DOOR {number}', font('barlow-semibold.ttf', 34), GOLD + (255,), 8))
bar.alpha_composite(line, ((W - line.width) // 2, (92 - line.height) // 2))
place(canvas, bar, 0, H - 92 + kf(t, [(2.3, 30), (2.8, 0)], ease_out), band)
def draw_advent25(self, canvas, pts, t):
self.draw_advent(canvas, pts, t, '25', 'THE MUPPET CHRISTMAS CAROL', big=True)
def draw_advent_app(self, canvas, pts, t):
pass
def draw_advent25_app(self, canvas, pts, t):
# The greeting and Door 25's strap never change, so they're in the clip; the film is the app's.
self.draw_advent(canvas, pts, t, '25', '', big=True)
def draw_naughty(self, canvas, pts, t):
# The room's gone dark by 3D's end; the title bleeds in, with one flicker, and holds.
a = kf(t, [(2.95, 0), (3.1, .9), (3.16, .25), (3.24, 1)], ease_io)
if a <= 0:
return
top = self.cache.get('ad') or self.cache.setdefault('ad', text_layer('AFTER DARK', font('anton-regular.ttf', 70), BLOOD + (255,), 18))
main = self.cache.get('nl')
if main is None:
main = chrome('THE NAUGHTY LIST', font('anton-regular.ttf', 118), 6, [(0, (232, 36, 40)), (.5, (178, 8, 18)), (.56, (96, 0, 6)), (1, (150, 6, 14))], (12, 0, 0), shear=0, outline=3)
self.cache['nl'] = main
tag = self.cache.get('tag') or self.cache.setdefault('tag', text_layer('“Not everyone makes the nice list.”', font('barlow-regular.ttf', 36), (232, 220, 214, 255), 2))
y = 210
place(canvas, glow(top, 16, .9), W / 2, y, a * .8, 'mt'); place(canvas, top, W / 2, y, a, 'mt')
place(canvas, glow(main, 22, 1.0), W / 2, y + 96, a * .8, 'mt'); place(canvas, main, W / 2, y + 96, a, 'mt')
place(canvas, tag, W / 2, y + 260, kf(t, [(3.2, 0), (3.45, 1)], ease_io), 'mt')
SOUNDS = {
'advent': lambda: riot.mix(LENGTH, [(1.0, b3.shimmer(1.4, 71), .3), (1.9, b3.bell(784.0), .45), (2.3, b3.bell(1046.5), .3)]),
'advent25': lambda: riot.mix(LENGTH, [(.8, b3.shimmer(2.0, 72), .35), (1.7, b3.bell(659.3), .45), (2.0, b3.bell(784.0), .4), (2.3, b3.bell(1046.5), .4)]),
'advent_app': lambda: SOUNDS['advent'](),
'advent25_app': lambda: SOUNDS['advent25'](),
'naughty': lambda: riot.mix(LENGTH, [(.3, b3.bell(1318.5, 1.2), .2), (1.4, b3.bell(1244.5, 1.2), .2), (2.7, riot.thump(.6, 55, 24, .4, 73), .9)]),
}
def guide_card(key, d, stem):
"""Advent's card is shared by four channels, so it carries no channel logo; The Naughty List's carries After Dark's."""
card = Image.new('RGBA', (512, 160))
if key == 'naughty':
epg = Image.open(b3.DESIGNS / 'orbit-after-dark' / 'exports' / 'orbit_after_dark_epg.png').convert('RGBA')
epg = scaled(epg.crop(epg.getbbox()), .74)
card.alpha_composite(epg, (10, round((160 - epg.height) / 2)))
lines = [text_layer('THE NAUGHTY', font('anton-regular.ttf', 30), (230, 30, 40, 255), 2), text_layer('LIST', font('anton-regular.ttf', 30), (230, 30, 40, 255), 2)]
x = 330
else:
lines = [text_layer('ADVENT', font('anton-regular.ttf', 48), GOLD + (255,), 6), text_layer('ON ORBIT', font('barlow-semibold.ttf', 26), (255, 255, 255, 255), 8)]
x = None
total = sum(l.height for l in lines) + 6
y = (160 - total) / 2
for layer in lines:
card.alpha_composite(layer, (x if x is not None else (512 - layer.width) // 2, round(y))); y += layer.height + 6
card.save(d / 'exports' / f'{stem}_guide.png')
card.resize((256, 80), Image.LANCZOS).save(d / 'exports' / f'{stem}_guide_app.webp', quality=90)
b3.BLOCKS.clear(); b3.BLOCKS.update(BLOCKS)
b3.SOUNDS.clear(); b3.SOUNDS.update(SOUNDS)
b3.Block, b3.guide_card = Block, guide_card
def review_board():
"""The three final holds and guide cards on one page, leaving Batch 3's own board as it was."""
batch3 = HERE / 'batch3_review.png'
kept = batch3.read_bytes()
b3.review_board()
batch3.replace(HERE / 'batch7_review.png')
batch3.write_bytes(kept)
if __name__ == '__main__':
frames = sys.argv[1]
for key in sys.argv[2:] or list(BLOCKS):
b3.build(key, frames)
review_board()