Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

2.9 KB
Raw Blame
#!/usr/bin/env python3
"""The Focus face's engine marks: 56 px, where the octopus stands on its skin.

    python3 devices/harness-device/firmware/scripts/gen_focus_marks.py

The 20 px marks (lvgl_icons.c) were downscaled from the web's engine icons; upscaling them would
draw a blur. These come from the same art at full resolution, as the desktop app vendors it
(desktop/assets/engine-icons, and model-icons/claude.png for Claude). Each is cropped to its own ink
first, then fitted into INK px and centred in the SIZE px square: the sources carry different
margins, so fitting them whole drew Claude edge to edge and Codex a size smaller. INK is 60% of
what Codex's art had on glass (owner, 2026-10-01). Writes main/ui/habitat/focus_marks.c:
ht_icon_engine56[14], RGB565 in panel order + alpha, in the order of ENGINES in focus.c.
"""
from pathlib import Path

from PIL import Image, ImageOps

root = Path(__file__).resolve().parents[1]
repo = root.parents[2]
SIZE = 56
INK = 48
# One list with ENGINES in main/ui/habitat/focus.c.
ENGINES = ['claude', 'codex', 'cursor', 'opencode', 'grok', 'copilot', 'amp',
           'devin', 'kilo', 'pi', 'hermes', 'muse', 'agy', 'commandcode']


def source(engine):
    if engine == 'claude':
        return repo / 'desktop/assets/model-icons/claude.png'
    return repo / f'desktop/assets/engine-icons/{engine}.png'


def mark(engine):
    img = Image.open(source(engine)).convert('RGBA')
    img = img.crop(img.getchannel('A').getbbox())
    fitted = ImageOps.contain(img, (INK, INK), Image.Resampling.LANCZOS)
    canvas = Image.new('RGBA', (SIZE, SIZE), (0, 0, 0, 0))
    canvas.alpha_composite(fitted, ((SIZE - fitted.width) // 2, (SIZE - fitted.height) // 2))
    return canvas


def emit(name, img):
    """RGB565, byte-swapped for the panel, and straight alpha — the layout of lvgl_icons.c."""
    px, alpha = [], []
    for r, g, b, a in img.get_flattened_data():
        v = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)
        px.append(((v << 8) | (v >> 8)) & 0xFFFF)
        alpha.append(a)
    return (f'static const uint16_t {name}_px[] = {{' + ','.join(map(str, px)) + '};\n'
            f'static const uint8_t {name}_a[] = {{' + ','.join(map(str, alpha)) + '};\n',
            f'{{{SIZE},{SIZE},{name}_px,{name}_a}}')


def main():
    out = ['// Generated by scripts/gen_focus_marks.py. Do not edit.\n'
           '// The engine marks at 56 px, from desktop/assets (engine-icons, model-icons/claude.png).\n'
           '#include "terminal.h"\n']
    refs = []
    for engine in ENGINES:
        code, ref = emit(f'engine56_{engine}', mark(engine))
        out.append(code)
        refs.append(ref)
    out.append(f'const ht_icon_t ht_icon_engine56[{len(ENGINES)}] = {{' + ','.join(refs) + '};\n')
    target = root / 'main/ui/habitat/focus_marks.c'
    target.write_text(''.join(out))
    print(f'{target}: {len(ENGINES)} marks, {len(ENGINES) * SIZE * SIZE * 3} bytes')


if __name__ == '__main__':
    main()