PulseCanvas / app · pulsecanvas.ai / scripts / prepare-platform-icons.py
| 1 | #!/usr/bin/env python3 |
| 2 | """Package the existing PulseCanvas mark in Apple's layered visionOS icon format. |
| 3 | Requires Pillow. Does not generate a new brand image. |
| 4 | """ |
| 5 | import json |
| 6 | from pathlib import Path |
| 7 | from PIL import Image |
| 8 | root=Path(__file__).resolve().parents[1] |
| 9 | mark=Image.open(root/'assets/app-icon/PulseCanvas-Octagon.png').convert('RGBA') |
| 10 | info={'author':'xcode','version':1} |
| 11 | def write(folder: Path, value: dict) -> None: |
| 12 | folder.mkdir(parents=True,exist_ok=True);(folder/'Contents.json').write_text(json.dumps(value,indent=2)+'\n') |
| 13 | vision=root/'visionOS/Assets.xcassets';write(vision,{'info':info}) |
| 14 | stack=vision/'AppIcon.solidimagestack';write(stack,{'info':info,'layers':[{'filename':n+'.solidimagestacklayer'} for n in ['Front','Back']]}) |
| 15 | for name in ['Front','Back']: |
| 16 | layer=stack/(name+'.solidimagestacklayer');write(layer,{'info':info});content=layer/'Content.imageset' |
| 17 | write(content,{'info':info,'images':[{'idiom':'vision','scale':'2x','filename':'icon.png'}]}) |
| 18 | # Let visionOS apply its circular mask to a full-bleed brand image. Placing an |
| 19 | # opaque square in the foreground creates a smaller black box inside that mask. |
| 20 | canvas=Image.new('RGBA',(1024,1024),(0,0,0,0)) |
| 21 | if name=='Back':canvas=mark.resize((1024,1024),Image.Resampling.LANCZOS) |
| 22 | canvas.save(content/'icon.png') |
| 23 | print('Packaged existing brand mark for visionOS') |