Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
237 lines
13 KiB
Python
237 lines
13 KiB
Python
#!/usr/bin/env python3
|
|
"""Batch 6 block idents, previews for Paul's review (4 November 2026, step 2 of the agreed order): Vortex Prime, the
|
|
bright afternoon block, and Afterburn, the darker late block, with a premiere version of Afterburn for the
|
|
vortex.afterburn.premiere key.
|
|
|
|
The 3D is Vortex's own tube of light from blender/build_block_ident.py (prime and afterburn, recoloured); the premiere
|
|
shares Afterburn's frames. This lays the 2D on top the way Batch 3 does, reusing its chrome, glint, guide cards and
|
|
checks unchanged. The channel logo and scenes are read only. Writes vortex-blocks/prime, afterburn and
|
|
afterburn-premiere. Nothing here is in the app until Paul approves it.
|
|
|
|
build-batch6-blocks.py <blender-blocks folder> [prime|afterburn|premiere] ...
|
|
"""
|
|
from pathlib import Path
|
|
import importlib.util, math, random, 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, glint = b3.text_layer, b3.place, b3.scaled, b3.font, b3.chrome, b3.glint
|
|
W, H, LENGTH = b3.W, b3.H, b3.LENGTH
|
|
|
|
BLOCKS = {
|
|
'prime': dict(title='Vortex Prime', folder='vortex-blocks/prime', channel='vortex', scene='prime'),
|
|
'afterburn': dict(title='Afterburn', folder='vortex-blocks/afterburn', channel='vortex', scene='afterburn'),
|
|
'premiere': dict(title='Afterburn premiere', folder='vortex-blocks/afterburn-premiere', channel='vortex', scene='afterburn'),
|
|
}
|
|
CANDY = [(0, (255, 255, 255)), (.3, (120, 236, 255)), (.48, (34, 216, 255)), (.52, (255, 47, 168)), (.75, (255, 120, 200)), (1, (255, 210, 30))]
|
|
HEAT = [(0, (255, 248, 222)), (.35, (255, 214, 120)), (.5, (255, 122, 18)), (.56, (190, 26, 6)), (1, (255, 150, 40))]
|
|
|
|
|
|
class Block(b3.Block):
|
|
def __init__(self, key, frames):
|
|
# The premiere shares Afterburn's 3D frames.
|
|
self.key, self.cfg, self.frames, self.points, self.cache = key, BLOCKS[key], Path(frames) / BLOCKS[key]['scene'], {}, {}
|
|
logo = Image.open(b3.DESIGNS / 'vortex' / 'exports' / 'vortex_primary.png').convert('RGBA')
|
|
self.logo = logo.crop(logo.getbbox())
|
|
|
|
def scene(self, t):
|
|
n = min(b3.MOVE, max(1, int(t * b3.FPS) + 1))
|
|
if self.cache.get('scene_n') != n:
|
|
self.cache['scene_n'], self.cache['scene'] = n, Image.open(self.frames / f'frame_{n:04d}.png').convert('RGBA')
|
|
return self.cache['scene'].copy(), {}
|
|
|
|
def title(self, words, size, stops, edge, spacing=6):
|
|
key = ('title', words, size)
|
|
if key not in self.cache:
|
|
self.cache[key] = chrome(words, font('anton-regular.ttf', size), spacing, stops, edge)
|
|
return self.cache[key]
|
|
|
|
def strapline(self, words, colour):
|
|
key = ('strap', words)
|
|
if key not in self.cache:
|
|
self.cache[key] = text_layer(words, font('barlow-semibold.ttf', 26), colour + (255,), 10)
|
|
return self.cache[key]
|
|
|
|
def band(self, canvas, amount, y=330, height=330):
|
|
if amount <= 0:
|
|
return
|
|
shade = self.cache.get(('band', y))
|
|
if shade is None:
|
|
shade = Image.new('L', (W, H), 0)
|
|
ImageDraw.Draw(shade).rounded_rectangle((-200, y - height / 2, W + 200, y + height / 2), 120, fill=200)
|
|
shade = shade.filter(ImageFilter.GaussianBlur(70))
|
|
self.cache[('band', y)] = shade
|
|
dark = Image.new('RGBA', (W, H), (0, 0, 0, 0)); dark.putalpha(shade.point(lambda v: round(v * amount)))
|
|
canvas.alpha_composite(dark)
|
|
|
|
# ---- Vortex Prime: the rush stays bright; PRIME slams in from the tunnel's centre with speed lines -------------
|
|
def draw_prime(self, canvas, pts, t):
|
|
self.channel_logo(canvas, t, .9, 360, (44, 40))
|
|
lines = kf(t, [(1.15, 0), (1.35, 1), (2.0, 0)], ease_io)
|
|
self.band(canvas, kf(t, [(1.4, 0), (2.0, 1)], ease_io))
|
|
if lines > 0:
|
|
layer = Image.new('RGBA', (W, H)); d = ImageDraw.Draw(layer)
|
|
rng = random.Random(7)
|
|
for _ in range(46):
|
|
a = rng.uniform(0, 2 * math.pi)
|
|
r0, r1 = rng.uniform(170, 260), rng.uniform(420, 820)
|
|
colour = rng.choice([(34, 216, 255), (255, 47, 168), (255, 210, 30), (255, 255, 255)])
|
|
d.line((W / 2 + math.cos(a) * r0, H / 2 + math.sin(a) * r0, W / 2 + math.cos(a) * r1, H / 2 + math.sin(a) * r1), fill=colour + (round(200 * lines),), width=3)
|
|
canvas.alpha_composite(layer)
|
|
word = self.title('PRIME', 196, CANDY, (14, 6, 40), 10)
|
|
grow = kf(t, [(1.15, .25), (1.45, 1.08), (1.65, 1)], ease_out)
|
|
a = kf(t, [(1.15, 0), (1.3, 1)], ease_io)
|
|
if a > 0:
|
|
layer = glint(scaled(word, grow) if grow != 1 else word, kf(t, [(2.3, 0), (2.8, 1)], ease_io))
|
|
halo = glow(layer, 18, .8)
|
|
place(canvas, halo, (W - layer.width) / 2, 300 - layer.height / 2, a * .7)
|
|
place(canvas, layer, (W - layer.width) / 2, 300 - layer.height / 2, a)
|
|
strap = self.strapline('THE AFTERNOON RUSH', (255, 255, 255))
|
|
place(canvas, strap, W / 2, 432 + kf(t, [(1.8, 14), (2.2, 0)], ease_out), kf(t, [(1.8, 0), (2.2, 1)], ease_io), 'mt')
|
|
reach = kf(t, [(2.0, 0), (2.5, 1)], ease_io)
|
|
if reach > 0:
|
|
d = ImageDraw.Draw(canvas) # opaque bars, safe to draw straight on
|
|
for i, colour in enumerate([(34, 216, 255), (255, 47, 168), (255, 210, 30)]):
|
|
width = 140 * reach
|
|
d.rectangle((W / 2 - 210 + i * 140, 486, W / 2 - 210 + i * 140 + width, 492), fill=colour + (255,))
|
|
|
|
# ---- Afterburn: the word streaks in from the left trailing fire, hits with a burst and a jolt, and burns for a
|
|
# moment; the flames die to a still ember glow before the hold.
|
|
def flames(self, word, t, power):
|
|
"""Flames licking up off the letters: tapered tongues whose heights flicker, blurred and coloured by heat."""
|
|
pad = 90
|
|
mask = Image.new('L', (word.width, word.height + pad), 0)
|
|
d = ImageDraw.Draw(mask)
|
|
alpha = word.getchannel('A')
|
|
rng = random.Random(5)
|
|
for x in range(0, word.width, 5):
|
|
column = alpha.crop((x, 0, min(word.width, x + 5), word.height)).getbbox()
|
|
if not column:
|
|
continue
|
|
top = column[1] + pad
|
|
phase, speed = rng.uniform(0, 6.3), rng.uniform(9, 15)
|
|
h = power * (18 + 52 * (.5 + .5 * math.sin(t * speed + phase)) ** 2 + rng.uniform(0, 34))
|
|
d.polygon([(x - 3, top + 24), (x + 7, top + 24), (x + 2 + 8 * math.sin(t * 7 + phase), top - h)], fill=255)
|
|
mask = mask.filter(ImageFilter.GaussianBlur(4))
|
|
heat = b3.gradient_fill(mask, [(0, (255, 60, 0)), (.55, (255, 140, 20)), (.85, (255, 230, 150)), (1, (255, 250, 230))])
|
|
heat.putalpha(mask.point(lambda v: min(255, round(v * 1.6))))
|
|
return heat, pad
|
|
|
|
def draw_afterburn(self, canvas, pts, t, premiere=False):
|
|
self.channel_logo(canvas, t, 1.3, 340, (44, 40))
|
|
word = self.title('AFTERBURN', 150, HEAT, (24, 4, 2), 6)
|
|
y = 300 if not premiere else 326
|
|
x0 = (W - word.width) / 2
|
|
hit = 1.35
|
|
self.band(canvas, kf(t, [(1.2, 0), (2.0, 1)], ease_io), y + 30)
|
|
slide = kf(t, [(1.0, -W - 200), (hit, 40), (hit + .18, 0)], ease_out)
|
|
if t >= 1.0:
|
|
# The jolt: the whole picture kicks once at the hit.
|
|
kick = kf(t, [(hit, 1), (hit + .25, 0)], ease_io) if t >= hit else 0
|
|
if kick > 0:
|
|
shaken = canvas.copy()
|
|
canvas.paste((0, 0, 0, 255), (0, 0, W, H))
|
|
canvas.alpha_composite(shaken, (round(math.sin(t * 90) * 9 * kick), round(math.cos(t * 70) * 6 * kick)))
|
|
burst = kf(t, [(hit, 0), (hit + .06, 1), (hit + .7, 0)], ease_out)
|
|
if burst > 0:
|
|
flash = self.cache.get('flash')
|
|
if flash is None:
|
|
flash = Image.new('L', (W, H), 0)
|
|
ImageDraw.Draw(flash).ellipse((W / 2 - 520, y - 220, W / 2 + 520, y + 220), fill=255)
|
|
flash = flash.filter(ImageFilter.GaussianBlur(110))
|
|
self.cache['flash'] = flash
|
|
glare = Image.new('RGBA', (W, H), (255, 120, 30, 0)); glare.putalpha(flash.point(lambda v: round(v * .75 * burst)))
|
|
canvas.alpha_composite(glare)
|
|
layer = Image.new('RGBA', (W, H)); d = ImageDraw.Draw(layer)
|
|
rng = random.Random(9)
|
|
age = t - hit
|
|
for _ in range(70):
|
|
a, speed = rng.uniform(0, 2 * math.pi), rng.uniform(500, 1300)
|
|
r = speed * age * (1 - age * .6)
|
|
sx, sy = W / 2 + math.cos(a) * r * 1.5, y + math.sin(a) * r * .7
|
|
tail = 26 * burst
|
|
d.line((sx, sy, sx - math.cos(a) * tail * 1.5, sy - math.sin(a) * tail * .7), fill=(255, rng.randint(150, 240), 60, round(255 * burst)), width=3)
|
|
canvas.alpha_composite(layer)
|
|
power = kf(t, [(1.0, 1.4), (hit, 1.3), (hit + .4, 1), (2.7, .8), (3.3, 0)], ease_io)
|
|
if power > 0:
|
|
fire, pad = self.flames(word, t, power)
|
|
if t < hit:
|
|
# Moving fast: the fire streams out behind, stretched back along the slide.
|
|
fire = fire.resize((fire.width + 260, fire.height), Image.BILINEAR)
|
|
place(canvas, fire, x0 + slide - 260, y - word.height / 2 - pad)
|
|
else:
|
|
place(canvas, fire, x0 + slide, y - word.height / 2 - pad)
|
|
if t < hit:
|
|
for k in range(1, 5):
|
|
place(canvas, word, x0 + slide - k * 70, y - word.height / 2, .5 / k)
|
|
ember = glow(word, 20, 1.0)
|
|
place(canvas, ember, x0 + slide, y - word.height / 2, kf(t, [(hit, 1), (2.0, .55)], ease_io))
|
|
place(canvas, glint(word, kf(t, [(2.4, 0), (2.9, 1)], ease_io)), x0 + slide, y - word.height / 2)
|
|
if premiere:
|
|
tag = self.cache.get('tag')
|
|
if tag is None:
|
|
label = text_layer('PREMIERE', font('anton-regular.ttf', 44), (255, 255, 255, 255), 8)
|
|
tag = Image.new('RGBA', (label.width + 44, label.height + 10), (210, 22, 8, 255))
|
|
tag.alpha_composite(label, (22, 5))
|
|
self.cache['tag'] = tag
|
|
place(canvas, tag, W / 2, 158 + kf(t, [(1.9, -12), (2.25, 0)], ease_out), kf(t, [(1.9, 0), (2.25, 1)], ease_io), 'mt')
|
|
strap = self.strapline('FIRST ON ORBIT · NEW EPISODES TONIGHT', (255, 226, 176))
|
|
else:
|
|
strap = self.strapline('LATE NIGHT ON VORTEX', (255, 226, 176))
|
|
place(canvas, strap, W / 2, y + word.height / 2 + 26, kf(t, [(2.0, 0), (2.4, 1)], ease_io), 'mt')
|
|
|
|
def draw_premiere(self, canvas, pts, t):
|
|
self.draw_afterburn(canvas, pts, t, premiere=True)
|
|
|
|
|
|
def roar(n_sec=1.6, seed=61):
|
|
"""A low burner roar: filtered noise swelling and settling."""
|
|
rng, n, y, out = random.Random(seed), int(n_sec * riot.RATE), 0.0, []
|
|
for i in range(n):
|
|
u = i / n
|
|
y += (rng.uniform(-1, 1) - y) * .03
|
|
out.append(y * 3 * math.sin(math.pi * u) ** .6)
|
|
return out
|
|
|
|
|
|
SOUNDS = {
|
|
'prime': lambda: riot.mix(LENGTH, [(0, b3.falling_whoosh(), .5), (1.15, riot.thump(.3, 140, 60, .3, 41), .8), (1.15, b3.shimmer(1.0, 42), .3)]),
|
|
'afterburn': lambda: riot.mix(LENGTH, [(1.1, roar(), .7), (1.55, riot.thump(.5, 60, 28, .3, 43), .8)]),
|
|
'premiere': lambda: riot.mix(LENGTH, [(1.1, roar(), .7), (1.55, riot.thump(.5, 60, 28, .3, 43), .8), (1.9, b3.bell(659.3), .35)]),
|
|
}
|
|
|
|
|
|
def guide_lines(key):
|
|
if key == 'prime':
|
|
return [chrome('PRIME', font('anton-regular.ttf', 52), 3, CANDY, (14, 6, 40), outline=3)]
|
|
words = chrome('AFTERBURN', font('anton-regular.ttf', 40), 2, HEAT, (24, 4, 2), outline=3)
|
|
if key == 'premiere':
|
|
return [text_layer('PREMIERE', font('barlow-semibold.ttf', 24), (255, 90, 60, 255), 4), words]
|
|
return [words]
|
|
|
|
|
|
b3.BLOCKS.clear(); b3.BLOCKS.update(BLOCKS)
|
|
b3.SOUNDS.clear(); b3.SOUNDS.update(SOUNDS)
|
|
b3.Block, b3.guide_lines = Block, guide_lines
|
|
|
|
|
|
def review_board():
|
|
"""The three final holds and guide cards on one page."""
|
|
# Batch 3's board function writes batch3_review.png: keep Batch 3's own board as it was.
|
|
batch3 = HERE / 'batch3_review.png'
|
|
kept = batch3.read_bytes()
|
|
b3.review_board()
|
|
batch3.replace(HERE / 'batch6_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()
|