Files
OrbitTv/design/channels/blender/claw_marks.py
T
2026-11-03 00:32:01 +00:00

55 lines
2.6 KiB
Python

#!/usr/bin/env python3
"""Three claw marks slashed beside the Wild logo, as frames to lay over the finished ident, just before the logo settles.
claw_marks.py <logo_word.png> <logo copy without marks, to write> <out folder>
"""
import sys
from pathlib import Path
from PIL import Image, ImageDraw, ImageFilter
MARKS_FROM = 940
word = Image.open(sys.argv[1]).convert('RGBA')
word.paste((0, 0, 0, 0), (MARKS_FROM, 0, word.width, word.height))
word.save(sys.argv[2])
out = Path(sys.argv[3]); out.mkdir(parents=True, exist_ok=True)
SS = 2
# Each mark runs from its top right to its bottom left, widest in the middle. Screen position as compose_ident.sh places the logo.
MARKS = [dict(top=(668, 244), bottom=(626, 416), start=232), dict(top=(708, 236), bottom=(664, 422), start=238), dict(top=(748, 244), bottom=(704, 416), start=244)]
STROKE = 6
HALF = 11
def shape(mark, reach):
(tx, ty), (bx, by) = mark['top'], mark['bottom']
def at(u): return tx + (bx - tx) * u, ty + (by - ty) * u
points = [at(0)]
for u, side in ((.3, 1), (.6, 1)):
x, y = at(u * reach / 1); points.append((x + HALF * side * (1 - abs(u - .45)), y + 1))
points.append(at(reach))
for u, side in ((.6, -1), (.3, -1)):
x, y = at(u * reach / 1); points.append((x + HALF * side * (1 - abs(u - .45)) * .9, y - 1))
return [(x * SS, y * SS) for x, y in points]
def frame_picture(frame):
solid = Image.new('L', (1280 * SS, 720 * SS)); hot = Image.new('L', (1280 * SS, 720 * SS))
for mark in MARKS:
age = frame - mark['start']
if age < 0: continue
reach = min(1, (age + 1) / STROKE)
ImageDraw.Draw(solid).polygon(shape(mark, reach), fill=255)
heat = max(0, 1 - age / 16)
if heat: ImageDraw.Draw(hot).polygon(shape(mark, reach), fill=int(255 * heat))
picture = Image.new('RGBA', (1280 * SS, 720 * SS), (240, 128, 24, 0)); picture.putalpha(solid)
white = Image.new('RGBA', picture.size, (255, 240, 200, 255)); picture = Image.composite(white, picture, hot)
# A hot glow that dies back to a low ember.
glow_colour = Image.new('RGBA', picture.size, (255, 110, 20, 255))
glow = solid.filter(ImageFilter.GaussianBlur(16)).point(lambda v: v * .55 + 0)
under = glow_colour.copy(); under.putalpha(glow)
under.alpha_composite(picture)
return under.resize((1280, 720), Image.LANCZOS)
settled = frame_picture(MARKS[-1]['start'] + 40)
blank = Image.new('RGBA', (1280, 720))
for frame in range(1, 351):
if frame < MARKS[0]['start']: picture = blank
elif frame >= MARKS[-1]['start'] + 40: picture = settled
else: picture = frame_picture(frame)
picture.save(out / f'over_{frame:04d}.png')