Add ident refinements and real 3D Blender scenes
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 3m25s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m41s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-02 16:07:38 +00:00
co-authored by Claude Opus 5.5
parent bd5728ce5d
commit ddea835e11
3 changed files with 407 additions and 0 deletions
+240
View File
@@ -0,0 +1,240 @@
"""Real 3D scenes for channel idents, rendered by Blender on its own, with no add-ons.
blender -b -P build_3d_ident.py -- <scene> <out folder> [frame ...]
With frames, renders just those as stills to look at. Without, renders the whole 7 seconds as images.
The logo goes on afterwards, in compose_ident.sh, so it stays perfectly sharp.
"""
import bpy, math, random, sys
from mathutils import Vector
args = sys.argv[sys.argv.index('--') + 1:]
SCENE, OUT, FRAMES = args[0], args[1], [int(a) for a in args[2:]]
FPS, LENGTH = 50, 350
bpy.ops.wm.read_factory_settings(use_empty=True)
scene = bpy.context.scene
scene.render.engine = 'CYCLES'
prefs = bpy.context.preferences.addons['cycles'].preferences
prefs.compute_device_type = 'OPTIX'
prefs.get_devices()
for device in prefs.devices: device.use = device.type == 'OPTIX'
scene.cycles.device = 'GPU'
scene.cycles.samples = 48
scene.cycles.use_denoising = True
scene.cycles.denoiser = 'OPTIX'
scene.cycles.max_bounces = 3
scene.render.resolution_x, scene.render.resolution_y = 1280, 720
scene.render.fps = FPS
scene.frame_start, scene.frame_end = 1, LENGTH
scene.render.use_motion_blur = True
scene.render.motion_blur_shutter = .5
scene.render.film_transparent = False
scene.view_settings.view_transform = 'AgX'
scene.view_settings.look = 'AgX - Punchy'
scene.render.image_settings.file_format = 'PNG'
def hexrgb(h, a=1.0):
h = h.lstrip('#')
return tuple(((int(h[i:i + 2], 16) / 255) ** 2.2) for i in (0, 2, 4)) + (a,)
def material(name):
m = bpy.data.materials.new(name); m.use_nodes = True
return m, m.node_tree.nodes, m.node_tree.links
def ramp(nodes, stops):
r = nodes.new('ShaderNodeValToRGB')
while len(r.color_ramp.elements) > 1: r.color_ramp.elements.remove(r.color_ramp.elements[-1])
r.color_ramp.elements[0].position, r.color_ramp.elements[0].color = stops[0][0], hexrgb(stops[0][1], stops[0][2] if len(stops[0]) > 2 else 1)
for s in stops[1:]:
e = r.color_ramp.elements.new(s[0]); e.color = hexrgb(s[1], s[2] if len(s) > 2 else 1)
return r
def stars_world(density=.9, tint='#FFFFFF'):
world = bpy.data.worlds.new('space'); scene.world = world; world.use_nodes = True
n, l = world.node_tree.nodes, world.node_tree.links
out, bg = n['World Output'], n['Background']
tex = n.new('ShaderNodeTexVoronoi'); tex.inputs['Scale'].default_value = 420
coord = n.new('ShaderNodeTexCoord'); l.new(coord.outputs['Generated'], tex.inputs['Vector'])
r = n.new('ShaderNodeValToRGB'); r.color_ramp.elements[0].position = 0; r.color_ramp.elements[0].color = (1, 1, 1, 1)
r.color_ramp.elements[1].position = .05; r.color_ramp.elements[1].color = (0, 0, 0, 1)
l.new(tex.outputs['Distance'], r.inputs['Fac'])
sparse = n.new('ShaderNodeTexNoise'); sparse.inputs['Scale'].default_value = 60
l.new(coord.outputs['Generated'], sparse.inputs['Vector'])
mask = n.new('ShaderNodeMath'); mask.operation = 'GREATER_THAN'; mask.inputs[1].default_value = .52
l.new(sparse.outputs['Fac'], mask.inputs[0])
mult = n.new('ShaderNodeMath'); mult.operation = 'MULTIPLY'
l.new(r.outputs['Color'], mult.inputs[0]); l.new(mask.outputs[0], mult.inputs[1])
nebula = n.new('ShaderNodeTexNoise'); nebula.inputs['Scale'].default_value = 1.6; nebula.inputs['Detail'].default_value = 8
l.new(coord.outputs['Generated'], nebula.inputs['Vector'])
deep = ramp(n, [(0.36, '#02040C'), (.62, world_tint[0]), (.82, world_tint[1])])
l.new(nebula.outputs['Fac'], deep.inputs['Fac'])
add = n.new('ShaderNodeMix'); add.data_type = 'RGBA'; add.blend_type = 'ADD'; add.inputs[0].default_value = 1
l.new(deep.outputs['Color'], add.inputs[6])
gain = n.new('ShaderNodeMath'); gain.operation = 'MULTIPLY'; gain.inputs[1].default_value = 40
l.new(mult.outputs[0], gain.inputs[0]); l.new(gain.outputs[0], add.inputs[7])
l.new(add.outputs[2], bg.inputs['Color'])
bg.inputs['Strength'].default_value = 1
def camera_path(keys, lens=35):
"""keys: (frame, position, target). A slow glide that eases in and settles, as one move."""
data = bpy.data.cameras.new('cam'); data.lens = lens; data.clip_end = 2000
cam = bpy.data.objects.new('cam', data); bpy.context.collection.objects.link(cam); scene.camera = cam
goal = bpy.data.objects.new('goal', None); bpy.context.collection.objects.link(goal)
track = cam.constraints.new('TRACK_TO'); track.target = goal; track.track_axis = 'TRACK_NEGATIVE_Z'; track.up_axis = 'UP_Y'
for frame, position, target in keys:
cam.location = position; cam.keyframe_insert('location', frame=frame)
goal.location = target; goal.keyframe_insert('location', frame=frame)
for obj in (cam, goal):
for curve in obj.animation_data.action.layers[0].strips[0].channelbag(obj.animation_data.action_slot).fcurves if hasattr(obj.animation_data.action, 'layers') else obj.animation_data.action.fcurves:
for point in curve.keyframe_points:
point.interpolation = 'BEZIER'; point.handle_left_type = point.handle_right_type = 'AUTO_CLAMPED'
return cam
def sun(direction, strength, colour='#FFFFFF', angle=2):
"""direction: the way the light travels."""
data = bpy.data.lights.new('sun', 'SUN'); data.energy = strength; data.color = hexrgb(colour)[:3]; data.angle = math.radians(angle)
obj = bpy.data.objects.new('sun', data); obj.rotation_euler = Vector(direction).to_track_quat('-Z', 'Y').to_euler()
bpy.context.collection.objects.link(obj)
def spin(obj, axis, turns):
index = 'xyz'.index(axis)
obj.rotation_euler[index] = 0; obj.keyframe_insert('rotation_euler', index=index, frame=1)
obj.rotation_euler[index] = turns * math.tau; obj.keyframe_insert('rotation_euler', index=index, frame=LENGTH)
action = obj.animation_data.action
curves = action.layers[0].strips[0].channelbag(obj.animation_data.action_slot).fcurves if hasattr(action, 'layers') else action.fcurves
for curve in curves:
for point in curve.keyframe_points: point.interpolation = 'LINEAR'
def sphere(name, radius, segments=128):
bpy.ops.mesh.primitive_uv_sphere_add(segments=segments, ring_count=segments // 2, radius=radius)
obj = bpy.context.active_object; obj.name = name
bpy.ops.object.shade_smooth()
return obj
def planet(palette, ring_colours, bands=True):
"""A shaded world with a soft atmosphere, and rings that go round it and cast a shadow on it."""
body = sphere('planet', 10)
m, n, l = material('planet')
bsdf = n['Principled BSDF']; bsdf.inputs['Roughness'].default_value = .62
coord = n.new('ShaderNodeTexCoord')
noise = n.new('ShaderNodeTexNoise'); noise.inputs['Scale'].default_value = 1; noise.inputs['Detail'].default_value = 9; noise.inputs['Distortion'].default_value = .35
stretch = n.new('ShaderNodeVectorMath'); stretch.operation = 'MULTIPLY'; stretch.inputs[1].default_value = (.05, .05, .55)
l.new(coord.outputs['Object'], stretch.inputs[0]); l.new(stretch.outputs[0], noise.inputs['Vector'])
colour = ramp(n, palette)
l.new(noise.outputs['Fac'], colour.inputs['Fac'])
l.new(colour.outputs['Color'], bsdf.inputs['Base Color'])
body.data.materials.append(m)
spin(body, 'z', .06)
air = sphere('atmosphere', 10.22)
m, n, l = material('air')
out = n['Material Output']; n.remove(n['Principled BSDF'])
fresnel = n.new('ShaderNodeLayerWeight'); fresnel.inputs['Blend'].default_value = .2
power = n.new('ShaderNodeMath'); power.operation = 'POWER'; power.inputs[1].default_value = 5
l.new(fresnel.outputs['Facing'], power.inputs[0])
glow = n.new('ShaderNodeEmission'); glow.inputs['Color'].default_value = hexrgb(ring_colours[0]); glow.inputs['Strength'].default_value = 1.6
clear = n.new('ShaderNodeBsdfTransparent')
mix = n.new('ShaderNodeMixShader')
l.new(power.outputs[0], mix.inputs[0]); l.new(clear.outputs[0], mix.inputs[1]); l.new(glow.outputs[0], mix.inputs[2]); l.new(mix.outputs[0], out.inputs['Surface'])
air.data.materials.append(m)
air.visible_shadow = False
bpy.ops.mesh.primitive_circle_add(vertices=256, radius=24, fill_type='NOTHING'); ring = bpy.context.active_object; ring.name = 'rings'
bpy.ops.object.mode_set(mode='EDIT'); bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={'value': (0, 0, 0)})
bpy.ops.transform.resize(value=(13.5 / 24, 13.5 / 24, 1)); bpy.ops.object.mode_set(mode='OBJECT')
m, n, l = material('rings')
out = n['Material Output']; n.remove(n['Principled BSDF'])
coord = n.new('ShaderNodeTexCoord')
length = n.new('ShaderNodeVectorMath'); length.operation = 'LENGTH'; l.new(coord.outputs['Object'], length.inputs[0])
wave = n.new('ShaderNodeTexNoise'); wave.inputs['Scale'].default_value = 1; wave.inputs['Detail'].default_value = 10
combine = n.new('ShaderNodeCombineXYZ'); scale = n.new('ShaderNodeMath'); scale.operation = 'MULTIPLY'; scale.inputs[1].default_value = 2.8
l.new(length.outputs['Value'], scale.inputs[0]); l.new(scale.outputs[0], combine.inputs[0]); l.new(combine.outputs[0], wave.inputs['Vector'])
bands_ramp = ramp(n, [(.28, ring_colours[1], 0), (.42, ring_colours[1], .35), (.55, ring_colours[0], .9), (.72, '#FFFFFF', .75)])
l.new(wave.outputs['Fac'], bands_ramp.inputs['Fac'])
edge = n.new('ShaderNodeMapRange'); edge.inputs['From Min'].default_value = 13.5; edge.inputs['From Max'].default_value = 24
l.new(length.outputs['Value'], edge.inputs['Value'])
fade = ramp(n, [(0, '#000000'), (.06, '#FFFFFF'), (.9, '#FFFFFF'), (1, '#000000')])
l.new(edge.outputs['Result'], fade.inputs['Fac'])
alpha = n.new('ShaderNodeMath'); alpha.operation = 'MULTIPLY'
l.new(bands_ramp.outputs['Alpha'], alpha.inputs[0]); l.new(fade.outputs['Color'], alpha.inputs[1])
glow = n.new('ShaderNodeEmission'); l.new(bands_ramp.outputs['Color'], glow.inputs['Color']); glow.inputs['Strength'].default_value = .55
clear = n.new('ShaderNodeBsdfTransparent'); mix = n.new('ShaderNodeMixShader')
l.new(alpha.outputs[0], mix.inputs[0]); l.new(clear.outputs[0], mix.inputs[1]); l.new(glow.outputs[0], mix.inputs[2]); l.new(mix.outputs[0], out.inputs['Surface'])
ring.data.materials.append(m)
ring.rotation_euler = (math.radians(13), math.radians(-16), 0)
return body, ring
def black_hole():
"""Paradox. A dark sphere, a spinning disc of light around it, and the disc's far side bent up and over the top, as gravity does."""
hole = sphere('hole', 6)
m, n, l = material('hole'); n['Principled BSDF'].inputs['Base Color'].default_value = (0, 0, 0, 1); n['Principled BSDF'].inputs['Roughness'].default_value = 1; n['Principled BSDF'].inputs['Specular IOR Level'].default_value = 0
hole.data.materials.append(m)
def light_ring(name, inner, outer, tilt, strength, speed, palette):
bpy.ops.mesh.primitive_circle_add(vertices=512, radius=outer, fill_type='NOTHING'); ring = bpy.context.active_object; ring.name = name
bpy.ops.object.mode_set(mode='EDIT'); bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={'value': (0, 0, 0)})
bpy.ops.transform.resize(value=(inner / outer, inner / outer, 1)); bpy.ops.object.mode_set(mode='OBJECT')
m, n, l = material(name); out = n['Material Output']; n.remove(n['Principled BSDF'])
coord = n.new('ShaderNodeTexCoord')
length = n.new('ShaderNodeVectorMath'); length.operation = 'LENGTH'; l.new(coord.outputs['Object'], length.inputs[0])
angle = n.new('ShaderNodeMath'); angle.operation = 'ARCTAN2'
sep = n.new('ShaderNodeSeparateXYZ'); l.new(coord.outputs['Object'], sep.inputs[0]); l.new(sep.outputs['Y'], angle.inputs[0]); l.new(sep.outputs['X'], angle.inputs[1])
swirl = n.new('ShaderNodeCombineXYZ')
twist = n.new('ShaderNodeMath'); twist.operation = 'MULTIPLY'; twist.inputs[1].default_value = 5
l.new(length.outputs['Value'], twist.inputs[0]); l.new(twist.outputs[0], swirl.inputs[0])
# Going round on the unit circle, so the pattern meets itself with no seam.
unit = n.new('ShaderNodeVectorMath'); unit.operation = 'NORMALIZE'; l.new(coord.outputs['Object'], unit.inputs[0])
unit_x = n.new('ShaderNodeSeparateXYZ'); l.new(unit.outputs[0], unit_x.inputs[0])
for axis, target in (('X', 1), ('Y', 2)):
wide = n.new('ShaderNodeMath'); wide.operation = 'MULTIPLY'; wide.inputs[1].default_value = 1.6
l.new(unit_x.outputs[axis], wide.inputs[0]); l.new(wide.outputs[0], swirl.inputs[target])
noise = n.new('ShaderNodeTexNoise'); noise.inputs['Scale'].default_value = 1.2; noise.inputs['Detail'].default_value = 10
l.new(swirl.outputs[0], noise.inputs['Vector'])
streak = ramp(n, [(.3, '#000000'), (.68, '#FFFFFF')])
l.new(noise.outputs['Fac'], streak.inputs['Fac'])
heat = n.new('ShaderNodeMapRange'); heat.inputs['From Min'].default_value = inner; heat.inputs['From Max'].default_value = outer
l.new(length.outputs['Value'], heat.inputs['Value'])
colour = ramp(n, palette)
l.new(heat.outputs['Result'], colour.inputs['Fac'])
amount = n.new('ShaderNodeMath'); amount.operation = 'MULTIPLY'; amount.use_clamp = True
l.new(streak.outputs['Color'], amount.inputs[0]); l.new(colour.outputs['Alpha'], amount.inputs[1])
glow = n.new('ShaderNodeEmission'); l.new(colour.outputs['Color'], glow.inputs['Color']); glow.inputs['Strength'].default_value = strength
clear = n.new('ShaderNodeBsdfTransparent'); mix = n.new('ShaderNodeMixShader')
l.new(amount.outputs[0], mix.inputs[0]); l.new(clear.outputs[0], mix.inputs[1]); l.new(glow.outputs[0], mix.inputs[2]); l.new(mix.outputs[0], out.inputs['Surface'])
ring.data.materials.append(m)
ring.rotation_euler = tilt
if speed:
turn = bpy.data.objects.new(name + '_axis', None); bpy.context.collection.objects.link(turn)
turn.rotation_euler = tilt; ring.rotation_euler = (0, 0, 0); ring.parent = turn
spin(ring, 'z', speed)
return ring
hot = [(0, '#FFFFFF', 1), (.08, '#FFC8EE', 1), (.3, '#E84CCB', .9), (.65, '#5A2AC8', .5), (1, '#120A40', 0)]
light_ring('disc', 7.4, 30, (math.radians(9), math.radians(-14), 0), 2.6, 1.1, hot)
# The far side of the disc, bent up and over by the hole's gravity, facing the viewer as a halo.
halo = [(0, '#FFFFFF', 1), (.25, '#FFB4E8', .9), (.7, '#7A3AE0', .25), (1, '#120A40', 0)]
light_ring('halo', 6.15, 11.5, (math.radians(84), 0, 0), 2.4, .4, halo)
return hole, light_ring
if SCENE == 'orbit-1':
world_tint = ('#061A3C', '#0E3A6E')
stars_world()
sun((.8, .55, -.25), 4.2, '#FFF4E0')
planet([(.36, '#072E66'), (.45, '#1668B8'), (.53, '#3FA6E0'), (.6, '#A8DDF5'), (.67, '#1E7FC8'), (.76, '#0A3D7C')], ('#7FD4FF', '#3A7FC8'))
# Starts low through the rings and sweeps round, ending with the planet to the right of the logo.
camera_path([(1, (-30, -30, -7), (2, 0, 3)), (260, (-18, -62, 11), (-13, 0, 1)), (350, (-18, -62, 11), (-13, 0, 1))])
elif SCENE == 'paradox':
world_tint = ('#10062C', '#2A0F54')
stars_world()
hole, _ = black_hole()
camera_path([(1, (14, -150, 12), (0, 0, 0)), (260, (-19, -66, 8), (-14, 0, 1)), (350, (-19, -66, 8), (-14, 0, 1))], lens=38)
else:
raise SystemExit('unknown scene')
if FRAMES:
for frame in FRAMES:
scene.frame_set(frame)
scene.render.filepath = f'{OUT}/still_{frame:04d}.png'
bpy.ops.render.render(write_still=True)
else:
scene.render.filepath = f'{OUT}/frame_'
bpy.ops.render.render(animation=True)
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
# Frames from build_3d_ident.py into a finished ident: a soft start, then the channel's logo fading in over the end.
# compose_ident.sh <frames folder> <logo png> <out.mp4>
ffmpeg -nostdin -y -loglevel error -framerate 50 -i "$1/frame_%04d.png" -loop 1 -i "$2" -filter_complex \
"[1:v]scale=992:-1,format=rgba,fade=t=in:st=4.4:d=.8:alpha=1[logo];[0:v]fade=t=in:st=0:d=.3[scene];[scene][logo]overlay=x=(W-w)/2-110:y=(H-h)/2-30:shortest=1,format=yuv420p" \
-t 7 -c:v libx264 -preset slow -crf 18 -movflags +faststart -an "$3"
+161
View File
@@ -0,0 +1,161 @@
#!/usr/bin/env python3
"""Paul's notes on the 3D idents, 2 November 2026. New layers and recipes only: each changed file keeps a .v1 copy, and world-v1 holds the old films.
refine-idents.py <Orbit-Channel-Designs folder>
"""
import json, math, os, random, shutil, subprocess, sys
from pathlib import Path
from PIL import Image
D = Path(sys.argv[1])
ENV = dict(os.environ, XDG_DATA_HOME=str(Path(__file__).parents[2] / '.tooling/font-data'))
def svg(w, h, body, defs=''):
return f'<svg xmlns="http://www.w3.org/2000/svg" width="{w}" height="{h}" viewBox="0 0 {w} {h}"><defs>{defs}</defs>{body}</svg>'
def render(path, body):
src = path.with_suffix('.svg')
src.write_text(body)
subprocess.run(['vectorcraft-cli', 'convert', str(src), str(path)], env=ENV, check=True, stdout=subprocess.DEVNULL)
src.unlink()
def keep(path):
copy = path.with_name(path.name + '.v1')
if not copy.exists(): shutil.copy(path, copy)
def recipe(channel):
path = D / channel / 'sources/build-ident.json'
keep(path)
return path, json.loads((path.with_name(path.name + '.v1')).read_text())
def layer_steps(steps, label):
"""The file.import, rename and set steps belonging to one layer."""
out, current = [], None
for i, step in enumerate(steps):
if step['command'] == 'file.import': current = steps[i + 1]['params'].get('name')
if current == label and step['command'] not in ('comp.new',): out.append(step)
return out
def new_layer(channel, label, png, position=None, scale=66.6667):
steps = [{'command': 'file.import', 'params': {'paths': [str(png)], 'addToComp': True}}, {'command': 'layer.rename', 'params': {'layer': '#1', 'name': label}},
{'command': 'prop.set', 'params': {'layer': label, 'path': 'transform/scale', 'value': [scale, scale, 100]}}]
if position: steps.append({'command': 'prop.set', 'params': {'layer': label, 'path': 'transform/position', 'value': position}})
return steps
# Orbit 1, Orbit 2 and Sci-Fi: the rings now go round the planet, passing behind and in front of it.
PLANET = (1510 / 1.5, 390 / 1.5, 0)
for channel, colours in (('orbit-1', ('#8FD3FF', '#BFE9FF', '#5FB8F0')), ('orbit-2', ('#C9A8FF', '#E8EDF5', '#9A7BE8')), ('orbit-sci-fi', ('#7FE8FF', '#BDEBFF', '#3FC1FF'))):
exports = D / channel / 'exports'
rings = ''.join(f'<ellipse cx="1000" cy="1000" rx="{rx}" ry="{rx * .3:.0f}" fill="none" stroke="{c}" stroke-width="{w}" opacity="{o}"/>' for rx, c, w, o in ((430, colours[0], 16, .95), (560, colours[1], 7, .8), (700, colours[2], 5, .6)))
half = lambda y: f'<clipPath id="h"><rect x="-200" y="{y}" width="2400" height="1000"/></clipPath>'
# Tilted, so the same tilt runs through both halves.
render(exports / 'bg_ring_back.png', svg(2000, 2000, f'<g transform="rotate(-18 1000 1000)"><g clip-path="url(#h)">{rings}</g></g>', half(0)))
render(exports / 'bg_ring_front.png', svg(2000, 2000, f'<g transform="rotate(-18 1000 1000)"><g clip-path="url(#h)">{rings}</g></g>', half(1000)))
path, steps = recipe(channel)
out, current = [], None
for i, step in enumerate(steps):
if step['command'] == 'file.import': current = steps[i + 1]['params'].get('name')
if current and current.startswith('Background orbit_'): continue
if step['command'] == 'file.import' and current == 'Background planet':
out += new_layer(channel, 'Background ring_back', exports / 'bg_ring_back.png', list(PLANET))
if step['command'] == 'file.import' and current and current.startswith('Logo scrim'):
out += new_layer(channel, 'Background ring_front', exports / 'bg_ring_front.png', list(PLANET))
out.append(step)
path.write_text(json.dumps(out, indent=1))
# Riot: the green paper stops just past the word, here and in the logo itself.
exports = D / 'orbit-riot/exports'
for name in ('logo_paper', 'logo_accent'): keep(exports / f'{name}.png')
paper = Image.open(exports / 'logo_paper.png.v1').convert('RGBA')
left, top, right, bottom = paper.getbbox()
target = 1178
squeezed = paper.crop((left, top, right, bottom)).resize((target - left, bottom - top), Image.LANCZOS)
out = Image.new('RGBA', paper.size); out.paste(squeezed, (left, top)); out.save(exports / 'logo_paper.png')
accent = Image.open(exports / 'logo_accent.png.v1').convert('RGBA')
moved = Image.new('RGBA', accent.size); moved.paste(accent, (right - target, 0) if False else (-(right - target), 0)); moved.save(exports / 'logo_accent.png')
# ToonZ: the burst sits round the Z alone, so TOON can be read, and they arrive together with the word.
exports = D / 'toonz/exports'
keep(exports / 'logo_paint_splash.png')
splash = Image.open(exports / 'logo_paint_splash.png.v1').convert('RGBA')
box = splash.getbbox(); piece = splash.crop(box)
side = 290
piece = piece.resize((side, int(side * piece.height / piece.width)), Image.LANCZOS)
out = Image.new('RGBA', splash.size); out.alpha_composite(piece, (989 - piece.width // 2, 326 - piece.height // 2)); out.save(exports / 'logo_paint_splash.png')
path, steps = recipe('toonz')
for step in steps:
p = step['params']
if step['command'] == 'prop.addKey' and p.get('path') == 'transform/opacity' and p.get('layer') in ('Logo paint_splash', 'Logo paint splash', 'Logo accent') and 0 < p['time'] < 3:
p['time'] = 1.65 if p['value'] == 0 else 1.95
path.write_text(json.dumps(steps, indent=1))
# Horror: a house on the hill, its windows flickering red.
exports = D / 'orbit-horror/exports'
def house(body, roof):
return (f'<g fill="{body}"><rect x="1300" y="560" width="420" height="330"/><polygon points="1270,560 1510,380 1750,560"/><rect x="1180" y="640" width="150" height="250"/><polygon points="1160,640 1255,520 1350,640"/>'
f'<rect x="1690" y="470" width="110" height="420"/><polygon points="1670,470 1745,300 1820,470"/><rect x="1400" y="340" width="34" height="120"/><path d="M1745 300v-46M1255 520v-40" stroke="{body}" stroke-width="8"/></g>')
render(exports / 'bg_house.png', svg(1920, 1080, house('#0B0610', '#0B0610') + '<rect y="880" width="1920" height="200" fill="#0B0610"/>'))
windows = ''
for x, y, w, h in ((1350, 620, 60, 90), (1470, 620, 60, 90), (1590, 620, 60, 90), (1350, 760, 60, 90), (1590, 760, 60, 90), (1225, 700, 50, 80), (1720, 540, 50, 80), (1720, 690, 50, 80), (1482, 470, 36, 56)):
windows += f'<path d="M{x} {y + h}V{y + 20}Q{x + w / 2} {y - 12} {x + w} {y + 20}V{y + h}Z" fill="#FF2A1E"/><path d="M{x + w / 2} {y}V{y + h}M{x} {y + h * .5}H{x + w}" stroke="#0B0610" stroke-width="5"/>'
render(exports / 'bg_house_windows.png', svg(1920, 1080, f'<filter id="g" x="-30%" y="-30%" width="160%" height="160%"><feGaussianBlur stdDeviation="9"/></filter><g opacity=".8" filter="url(#g)">{windows}</g>{windows}'))
path, steps = recipe('orbit-horror')
out, current, placed = [], None, False
for i, step in enumerate(steps):
if step['command'] == 'file.import':
current = steps[i + 1]['params'].get('name')
if not placed and current in ('Background tree_3', 'Background mist'):
out += new_layer('orbit-horror', 'Background house', exports / 'bg_house.png') + new_layer('orbit-horror', 'Background house_windows', exports / 'bg_house_windows.png')
placed = True
out.append(step)
path.write_text(json.dumps(out, indent=1))
# BritX: over the Thames, under Tower Bridge's walkway height, to Big Ben.
channel = D / 'orbit-britx'; exports = channel / 'exports'
path = channel / 'sources/build-ident.json'
keep(path)
logo = [s for s in json.loads((channel / 'sources/build-ident.json.v1').read_text())]
comp, logo_steps = logo[0], logo[1:]
AMBER, STONE, NIGHT = '#E8A33D', '#1A2230', '#0B0F18'
rng = random.Random(115)
stars = ''.join(f'<circle cx="{rng.randrange(1920)}" cy="{rng.randrange(620)}" r="{rng.choice((1.5, 2, 2.5))}" fill="#DCE6F5" opacity="{rng.uniform(.3, .9):.2f}"/>' for _ in range(110))
render(exports / 'bg_sky.png', svg(1920, 1080, f'<rect width="1920" height="1080" fill="url(#s)"/>{stars}<circle cx="1120" cy="170" r="52" fill="#E8EDF5"/><circle cx="1120" cy="170" r="120" fill="url(#m)"/>',
'<linearGradient id="s" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#060A14"/><stop offset=".55" stop-color="#16233A"/><stop offset=".8" stop-color="#4A3226"/></linearGradient><radialGradient id="m"><stop offset=".3" stop-color="#E8EDF5" stop-opacity=".35"/><stop offset="1" stop-color="#E8EDF5" stop-opacity="0"/></radialGradient>'))
def windows(x, y, w, h, seed, rate=.35):
rng = random.Random(seed)
return ''.join(f'<rect x="{wx}" y="{wy}" width="8" height="12" fill="{AMBER}" opacity="{rng.uniform(.5, 1):.2f}"/>' for wy in range(y, y + h, 22) for wx in range(x, x + w, 18) if rng.random() < rate)
# The City, with a dome and tall towers, far off.
far = '<path d="M210 700V610Q210 540 280 530V490h14v40Q364 540 364 610V700Z" fill="#1A2436"/>'
for x, w, h, s in ((0, 140, 170, 1), (150, 70, 120, 2), (400, 110, 150, 3), (520, 80, 260, 4), (610, 130, 140, 5), (760, 70, 190, 6), (850, 150, 120, 7), (1010, 90, 170, 8)):
far += f'<rect x="{x}" y="{700 - h}" width="{w}" height="{h}" fill="#1A2436"/>' + windows(x + 8, 712 - h, w - 14, h - 24, s, .25)
far += '<polygon points="640,700 690,330 740,700" fill="#202C42"/>'
render(exports / 'bg_skyline.png', svg(1920, 1080, far))
# Parliament and the clock tower, where the flight ends.
ben = '<rect x="1000" y="640" width="920" height="70" fill="#141B28"/>' + ''.join(f'<polygon points="{x},640 {x + 10},600 {x + 20},640" fill="#141B28"/>' for x in range(1000, 1920, 46)) + windows(1010, 650, 900, 50, 9, .4)
ben += ('<rect x="1490" y="240" width="130" height="470" fill="#1E2736"/><rect x="1480" y="225" width="150" height="16" fill="#2A3548"/><polygon points="1490,225 1555,70 1620,225" fill="#1E2736"/><rect x="1551" y="30" width="8" height="50" fill="#2A3548"/>'
'<rect x="1478" y="245" width="154" height="154" fill="#2A3548"/><circle cx="1555" cy="322" r="66" fill="#FFE9B0"/><circle cx="1555" cy="322" r="66" fill="none" stroke="#141B28" stroke-width="7"/>'
'<path d="M1555 322V278M1555 322L1588 340" stroke="#141B28" stroke-width="7" stroke-linecap="round"/>' + ''.join(f'<rect x="{x}" y="420" width="12" height="270" fill="#141B28"/>' for x in (1510, 1540, 1570, 1600)))
render(exports / 'bg_big_ben.png', svg(1920, 1080, ben + '<circle cx="1555" cy="322" r="130" fill="url(#g)"/>', '<radialGradient id="g"><stop offset=".45" stop-color="#FFE9B0" stop-opacity=".35"/><stop offset="1" stop-color="#FFE9B0" stop-opacity="0"/></radialGradient>'))
river = '<rect y="700" width="1920" height="380" fill="url(#r)"/>' + ''.join(f'<rect x="{x}" y="{y}" width="{w}" height="4" fill="{AMBER}" opacity="{o}"/>' for x, y, w, o in ((1480, 730, 150, .6), (1500, 770, 110, .4), (1530, 820, 70, .3), (300, 760, 200, .3), (820, 740, 160, .3), (600, 860, 260, .2), (1100, 930, 300, .2)))
render(exports / 'bg_water.png', svg(1920, 1080, river, '<linearGradient id="r" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#1C2738"/><stop offset="1" stop-color="#06090F"/></linearGradient>'))
# Tower Bridge, which the camera flies over.
tower = lambda x: (f'<g><rect x="{x}" y="180" width="260" height="620" fill="{STONE}"/><polygon points="{x - 14},180 {x + 130},40 {x + 274},180" fill="#10161F"/>'
+ ''.join(f'<polygon points="{tx - 20},180 {tx},90 {tx + 20},180" fill="#10161F"/>' for tx in (x + 6, x + 254)) + windows(x + 20, 210, 220, 560, x, .3) + f'</g>')
bridge = tower(860) + tower(1680) + f'<rect x="1120" y="230" width="560" height="44" fill="{STONE}"/><rect x="1120" y="560" width="560" height="50" fill="#141B28"/>' + ''.join(f'<rect x="{x}" y="274" width="4" height="30" fill="#2A3548"/>' for x in range(1130, 1680, 26))
for x0, x1 in ((0, 860), (1940, 2800)):
bridge += f'<rect x="{x0}" y="560" width="{x1 - x0}" height="50" fill="#141B28"/>' + ''.join(f'<circle cx="{x}" cy="552" r="7" fill="{AMBER}"/>' for x in range(x0 + 40, x1, 120))
bridge += f'<path d="M{x0} {200 if x0 == 0 else 560}Q{(x0 + x1) / 2} {590 if x0 == 0 else 590} {x1} {560 if x0 == 0 else 200}" fill="none" stroke="#2A3548" stroke-width="14"/>'
(exports / 'pass_bridge.svg').write_text(svg(2800, 860, bridge))
steps = [comp] + new_layer('orbit-britx', 'Background sky', exports / 'bg_sky.png') + new_layer('orbit-britx', 'Background skyline', exports / 'bg_skyline.png') + new_layer('orbit-britx', 'Background big_ben', exports / 'bg_big_ben.png') + new_layer('orbit-britx', 'Background water', exports / 'bg_water.png') + logo_steps
path.write_text(json.dumps(steps, indent=1))
# Paradox: a black hole. The disc is drawn to spin as a real tilted plane, in build-world.py.
exports = D / 'paradox/exports'
streaks = ''
rng = random.Random(6)
for i in range(120):
r = rng.uniform(300, 950)
length = rng.uniform(.3, 1.2)
a = rng.uniform(0, math.tau)
x1, y1, x2, y2 = 1000 + r * math.cos(a), 1000 + r * math.sin(a), 1000 + r * math.cos(a + length), 1000 + r * math.sin(a + length)
colour = rng.choice(('#FFFFFF', '#FF9AE0', '#E84CCB', '#9A7BFF', '#37E5FF'))
streaks += f'<path d="M{x1:.0f} {y1:.0f}A{r:.0f} {r:.0f} 0 0 1 {x2:.0f} {y2:.0f}" fill="none" stroke="{colour}" stroke-width="{rng.uniform(3, 12):.1f}" opacity="{rng.uniform(.25, .8):.2f}" stroke-linecap="round"/>'
disc = '<radialGradient id="d"><stop offset=".26" stop-color="#FFFFFF" stop-opacity="0"/><stop offset=".3" stop-color="#FFE9F8"/><stop offset=".45" stop-color="#E84CCB"/><stop offset=".7" stop-color="#5A2AC8" stop-opacity=".75"/><stop offset="1" stop-color="#1A1050" stop-opacity="0"/></radialGradient>'
render(exports / 'hole_disc.png', svg(2000, 2000, f'<circle cx="1000" cy="1000" r="1000" fill="url(#d)"/>{streaks}', disc))
ball = '<radialGradient id="h"><stop offset=".78" stop-color="#000000"/><stop offset=".84" stop-color="#FFE9F8"/><stop offset=".9" stop-color="#E84CCB" stop-opacity=".7"/><stop offset="1" stop-color="#5A2AC8" stop-opacity="0"/></radialGradient>'
render(exports / 'hole_ball.png', svg(800, 800, '<circle cx="400" cy="400" r="400" fill="url(#h)"/>', ball))
arc = '<linearGradient id="a" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#FFE9F8"/><stop offset="1" stop-color="#E84CCB" stop-opacity=".2"/></linearGradient><filter id="b" x="-10%" y="-40%" width="120%" height="180%"><feGaussianBlur stdDeviation="6"/></filter>'
render(exports / 'hole_front.png', svg(2000, 500, '<path d="M60 250C480 400 1520 400 1940 250C1520 330 480 330 60 250Z" fill="url(#a)" filter="url(#b)"/>', arc))