Files

28 lines
1.7 KiB
Python

import json
from pathlib import Path
from PIL import Image, ImageDraw
root = Path(__file__).resolve().parents[1] / 'reimburse/Assets.xcassets/AppIcon.appiconset'
image = Image.new('RGBA', (1024, 1024))
draw = ImageDraw.Draw(image)
draw.rounded_rectangle((44, 44, 980, 980), radius=218, fill='#145b54')
draw.rounded_rectangle((72, 70, 952, 955), radius=194, fill='#1b7368')
draw.rounded_rectangle((284, 174, 743, 800), radius=42, fill='#f4f0e6')
draw.rounded_rectangle((350, 268, 665, 294), radius=13, fill='#90b2a8')
draw.rounded_rectangle((350, 341, 580, 363), radius=11, fill='#b1c7bd')
draw.rounded_rectangle((350, 405, 634, 427), radius=11, fill='#b1c7bd')
draw.rounded_rectangle((198, 488, 826, 817), radius=70, fill='#103e39')
draw.rounded_rectangle((218, 511, 806, 796), radius=54, fill='#224e46')
draw.rounded_rectangle((617, 582, 854, 726), radius=42, fill='#d6bd82')
draw.ellipse((662, 630, 709, 677), fill='#4c6351')
draw.line([(342, 645), (411, 707), (523, 584)], fill='#f4f0e6', width=29, joint='curve')
entries = []
for size in [16, 32, 128, 256, 512]:
for scale in [1, 2]:
filename = f'icon-{size}@{scale}x.png'
image.resize((size * scale, size * scale), Image.Resampling.LANCZOS).save(root / filename)
entries.append(dict(idiom='mac', size=f'{size}x{size}', scale=f'{scale}x', filename=filename))
content = json.dumps(dict(images=entries, info=dict(author='xcode', version=1)), indent=2)
import subprocess
subprocess.run(['apply_patch', '*** Begin Patch\n*** Delete File: ' + str(root / 'Contents.json') + '\n*** Add File: ' + str(root / 'Contents.json') + '\n' + '\n'.join('+' + line for line in content.splitlines()) + '\n*** End Patch'], check=True)