SpringBoard tweak for the iPhone XR on iOS 18.7.1 (Dopamine rootless), built without Theos using the swift.org clang and linked on the phone. The island shows music with Apple's audio analyzer and live lyrics, timers, calls, flashlight, screen recording, accessories and their batteries, calendar, notifications with actions, and system popups, in portrait and landscape. Includes a Settings page, a Watch ping hook, an offscreen self test and the tools that capture the showcase video. Co-Authored-By: Claude Opus 5.5 <[email protected]>
143 lines
6.4 KiB
Python
Executable file
143 lines
6.4 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# Turns the frames from tools/film into build/Islet-showcase.mp4: a phone mockup with a title for each scene.
|
|
import math, subprocess, sys
|
|
from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageChops
|
|
|
|
W, H, FPS = 1920, 1080, 30
|
|
FRAMES = 'build/film'
|
|
OUT = 'build/Islet-showcase.mp4'
|
|
FONT = '/usr/share/fonts/TTF/Roboto-%s.ttf'
|
|
SCREEN = (760, 1645) # the phone's screen in the video
|
|
INTRO, OUTRO = 2.2, 2.6
|
|
TINT = {'Battery': (48, 209, 88), 'Accessories': (10, 132, 255), 'Music': (255, 55, 130), 'Activities': (255, 159, 10), 'System': (175, 82, 222),
|
|
'Notifications': (64, 200, 224), 'Gestures': (255, 214, 10), 'Landscape': (255, 69, 58)}
|
|
|
|
def ease(x):
|
|
x = max(0, min(1, x)); return 1 - (1 - x) ** 3
|
|
|
|
def font(style, size): return ImageFont.truetype(FONT % style, size)
|
|
|
|
scenes, frames = [], []
|
|
for line in open(FRAMES + '/frames.txt', encoding='utf-8'):
|
|
p = line.split(' ', 3)
|
|
if p[0] == 'scene':
|
|
group, title = p[3].strip().split('|')
|
|
scenes.append(dict(t=float(p[1]), code=int(p[2]), group=group, title=title))
|
|
else:
|
|
frames.append((float(p[1]), int(p[2])))
|
|
end = frames[-1][0]
|
|
for i, s in enumerate(scenes): s['end'] = scenes[i + 1]['t'] if i + 1 < len(scenes) else end
|
|
|
|
def backdrop(c):
|
|
im = Image.new('RGB', (W // 8, H // 8), (9, 9, 12))
|
|
d = ImageDraw.Draw(im)
|
|
d.ellipse((W // 8 - 150, -70, W // 8 + 40, 120), fill=tuple(int(v * 0.36) for v in c))
|
|
return im.filter(ImageFilter.GaussianBlur(26)).resize((W, H), Image.BICUBIC)
|
|
|
|
def phone_parts():
|
|
bw, sw, sh = 26, *SCREEN
|
|
k = 2
|
|
outer = Image.new('RGBA', ((sw + bw * 2) * k, (sh + bw * 2) * k), (0, 0, 0, 0))
|
|
d = ImageDraw.Draw(outer)
|
|
d.rounded_rectangle((0, 0, outer.width - 1, outer.height - 1), radius=106 * k, fill=(52, 52, 58, 255))
|
|
d.rounded_rectangle((4 * k, 4 * k, outer.width - 1 - 4 * k, outer.height - 1 - 4 * k), radius=102 * k, fill=(10, 10, 12, 255))
|
|
outer = outer.resize((sw + bw * 2, sh + bw * 2), Image.LANCZOS)
|
|
mask = Image.new('L', (sw * k, sh * k), 0)
|
|
ImageDraw.Draw(mask).rounded_rectangle((0, 0, sw * k - 1, sh * k - 1), radius=80 * k, fill=255)
|
|
return outer, mask.resize((sw, sh), Image.LANCZOS), bw
|
|
|
|
BODY, MASK, BEZEL = phone_parts()
|
|
|
|
def caption(s, index, total):
|
|
c = TINT[s['group']]
|
|
im = Image.new('RGBA', (W, H), (0, 0, 0, 0))
|
|
d = ImageDraw.Draw(im)
|
|
if s['code'] in (114, 115):
|
|
d.text((110, 62), s['group'].upper(), font=font('Medium', 26), fill=c + (255,))
|
|
d.text((108, 96), s['title'], font=font('Bold', 72), fill=(255, 255, 255, 255))
|
|
else:
|
|
x = 960
|
|
d.text((x, 408), s['group'].upper(), font=font('Medium', 30), fill=c + (255,))
|
|
t, size = s['title'], 96
|
|
while font('Bold', size).getlength(t) > W - x - 90: size -= 4
|
|
d.text((x - 3, 452), t, font=font('Bold', size), fill=(255, 255, 255, 255))
|
|
d.text((x, 590), '%d of %d' % (index + 1, total), font=font('Regular', 26), fill=(255, 255, 255, 110))
|
|
return im
|
|
|
|
CAPTIONS = [caption(s, i, len(scenes)) for i, s in enumerate(scenes)]
|
|
BACK = {g: backdrop(c) for g, c in TINT.items()}
|
|
PLAIN = backdrop((90, 80, 200))
|
|
|
|
def angle_for(code): return 90 if code == 114 else -90 if code == 115 else 0
|
|
|
|
def frame_at(t):
|
|
lo, hi = 0, len(frames) - 1
|
|
while lo < hi:
|
|
mid = (lo + hi + 1) // 2
|
|
if frames[mid][0] <= t: lo = mid
|
|
else: hi = mid - 1
|
|
return Image.open('%s/f%05d.jpg' % (FRAMES, frames[lo][1])).convert('RGB')
|
|
|
|
def draw_phone(canvas, screen, angle, centre):
|
|
body = BODY.copy()
|
|
body.paste(screen.resize(SCREEN, Image.BILINEAR), (BEZEL, BEZEL), MASK)
|
|
if abs(angle) > 0.01: body = body.rotate(angle, resample=Image.BILINEAR, expand=True)
|
|
canvas.paste(body, (int(centre[0] - body.width / 2), int(centre[1] - body.height / 2)), body)
|
|
|
|
PORTRAIT = (500, 70 + BODY.height // 2)
|
|
LAND = (W // 2, 640)
|
|
|
|
def lerp(a, b, x): return (a[0] + (b[0] - a[0]) * x, a[1] + (b[1] - a[1]) * x)
|
|
|
|
def titled(lines, alpha):
|
|
im = PLAIN.copy()
|
|
layer = Image.new('RGBA', (W, H), (0, 0, 0, 0))
|
|
d = ImageDraw.Draw(layer)
|
|
for text, f, y, fill in lines:
|
|
d.text(((W - f.getlength(text)) / 2, y), text, font=f, fill=fill)
|
|
layer.putalpha(layer.getchannel('A').point(lambda v: int(v * alpha)))
|
|
im.paste(layer, (0, 0), layer)
|
|
return im
|
|
|
|
INTRO_LINES = [('Islet', font('Bold', 170), 380, (255, 255, 255, 255)), ('A Dynamic Island for notched iPhones', font('Light', 48), 590, (255, 255, 255, 200))]
|
|
OUTRO_LINES = [('Islet 0.7.6', font('Bold', 120), 370, (255, 255, 255, 255)), ('iPhone XR, iOS 18.7.1, Dopamine rootless', font('Light', 42), 530, (255, 255, 255, 200)),
|
|
('Real island code captured on the device. Mock wallpaper and demo content.', font('Regular', 28), 640, (255, 255, 255, 120))]
|
|
|
|
ff = subprocess.Popen(['ffmpeg', '-y', '-loglevel', 'error', '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-s', '%dx%d' % (W, H), '-r', str(FPS), '-i', '-',
|
|
'-c:v', 'libx264', '-preset', 'medium', '-crf', '18', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', OUT], stdin=subprocess.PIPE)
|
|
def emit(im): ff.stdin.write(im.tobytes())
|
|
|
|
for n in range(int(INTRO * FPS)):
|
|
t = n / FPS
|
|
emit(titled(INTRO_LINES, min(ease(t / 0.5), ease((INTRO - t) / 0.3))))
|
|
|
|
n, total = 0, int((end - scenes[0]['t']) * FPS)
|
|
prev_angle = 0
|
|
for i, s in enumerate(scenes):
|
|
a0, a1 = prev_angle, angle_for(s['code'])
|
|
frames_here = int((s['end'] - s['t']) * FPS)
|
|
for k in range(frames_here):
|
|
local = k / FPS
|
|
t = s['t'] + local
|
|
canvas = BACK[s['group']].copy()
|
|
x = ease(local / 0.42)
|
|
angle = a0 + (a1 - a0) * x
|
|
# the phone moves to the middle as it turns
|
|
turned = min(abs(angle) / 90, 1)
|
|
draw_phone(canvas, frame_at(t), angle, lerp(PORTRAIT, LAND, turned))
|
|
fade = ease(local / 0.22)
|
|
cap = CAPTIONS[i]
|
|
if fade < 1:
|
|
cap = cap.copy(); cap.putalpha(cap.getchannel('A').point(lambda v: int(v * fade)))
|
|
canvas.paste(cap, (0, int((1 - fade) * 18)), cap)
|
|
ImageDraw.Draw(canvas).rectangle((0, H - 6, int(W * (n / max(total, 1))), H), fill=TINT[s['group']])
|
|
emit(canvas)
|
|
n += 1
|
|
prev_angle = a1
|
|
print('\r%d/%d' % (n, total), end='', file=sys.stderr)
|
|
|
|
for k in range(int(OUTRO * FPS)):
|
|
t = k / FPS
|
|
emit(titled(OUTRO_LINES, min(ease(t / 0.5), ease((OUTRO - t) / 0.4))))
|
|
ff.stdin.close(); ff.wait()
|
|
print('\nwrote', OUT, file=sys.stderr)
|