From ddea835e113dd943630558c55a523c1b5faa0c68 Mon Sep 17 00:00:00 2001 From: Pauljd Date: Mon, 2 Nov 2026 16:07:38 +0000 Subject: [PATCH] Add ident refinements and real 3D Blender scenes Co-Authored-By: Claude Opus 5.5 (1M context) --- design/channels/blender/build_3d_ident.py | 240 ++++++++++++++++++++++ design/channels/blender/compose_ident.sh | 6 + design/channels/refine-idents.py | 161 +++++++++++++++ 3 files changed, 407 insertions(+) create mode 100644 design/channels/blender/build_3d_ident.py create mode 100755 design/channels/blender/compose_ident.sh create mode 100644 design/channels/refine-idents.py diff --git a/design/channels/blender/build_3d_ident.py b/design/channels/blender/build_3d_ident.py new file mode 100644 index 00000000..1bb7b9e1 --- /dev/null +++ b/design/channels/blender/build_3d_ident.py @@ -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 -- [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) diff --git a/design/channels/blender/compose_ident.sh b/design/channels/blender/compose_ident.sh new file mode 100755 index 00000000..540bcecf --- /dev/null +++ b/design/channels/blender/compose_ident.sh @@ -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 +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" diff --git a/design/channels/refine-idents.py b/design/channels/refine-idents.py new file mode 100644 index 00000000..dbe687b0 --- /dev/null +++ b/design/channels/refine-idents.py @@ -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 +""" +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'{defs}{body}' +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'' 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'' + # Tilted, so the same tilt runs through both halves. + render(exports / 'bg_ring_back.png', svg(2000, 2000, f'{rings}', half(0))) + render(exports / 'bg_ring_front.png', svg(2000, 2000, f'{rings}', 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'' + f'') +render(exports / 'bg_house.png', svg(1920, 1080, house('#0B0610', '#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'' +render(exports / 'bg_house_windows.png', svg(1920, 1080, f'{windows}{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'' for _ in range(110)) +render(exports / 'bg_sky.png', svg(1920, 1080, f'{stars}', + '')) +def windows(x, y, w, h, seed, rate=.35): + rng = random.Random(seed) + return ''.join(f'' 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 = '' +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'' + windows(x + 8, 712 - h, w - 14, h - 24, s, .25) +far += '' +render(exports / 'bg_skyline.png', svg(1920, 1080, far)) +# Parliament and the clock tower, where the flight ends. +ben = '' + ''.join(f'' for x in range(1000, 1920, 46)) + windows(1010, 650, 900, 50, 9, .4) +ben += ('' + '' + '' + ''.join(f'' for x in (1510, 1540, 1570, 1600))) +render(exports / 'bg_big_ben.png', svg(1920, 1080, ben + '', '')) +river = '' + ''.join(f'' 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, '')) +# Tower Bridge, which the camera flies over. +tower = lambda x: (f'' + + ''.join(f'' for tx in (x + 6, x + 254)) + windows(x + 20, 210, 220, 560, x, .3) + f'') +bridge = tower(860) + tower(1680) + f'' + ''.join(f'' for x in range(1130, 1680, 26)) +for x0, x1 in ((0, 860), (1940, 2800)): + bridge += f'' + ''.join(f'' for x in range(x0 + 40, x1, 120)) + bridge += f'' +(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'' +disc = '' +render(exports / 'hole_disc.png', svg(2000, 2000, f'{streaks}', disc)) +ball = '' +render(exports / 'hole_ball.png', svg(800, 800, '', ball)) +arc = '' +render(exports / 'hole_front.png', svg(2000, 500, '', arc))