39 lines
1.4 KiB
Bash
Executable File
39 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Renders the three app-icon variants from appicon.html into the asset catalog.
|
|
#
|
|
# scripts/appicon/generate.sh
|
|
#
|
|
# Chrome is the rasteriser because it is the only thing on a stock Mac that
|
|
# renders SVG the same way the browser preview sheets in docs/ do. The PNGs it
|
|
# writes are build output — edit appicon.html, not them.
|
|
set -euo pipefail
|
|
|
|
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
OUT="$HERE/../../Marks/Assets.xcassets/AppIcon.appiconset"
|
|
CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
|
|
|
[ -x "$CHROME" ] || { echo "Google Chrome not found at $CHROME" >&2; exit 1; }
|
|
command -v magick >/dev/null || { echo "ImageMagick (magick) not found" >&2; exit 1; }
|
|
|
|
render() {
|
|
local variant=$1 name=$2
|
|
"$CHROME" --headless=new --disable-gpu --hide-scrollbars \
|
|
--default-background-color=00000000 \
|
|
--screenshot="$OUT/$name" --window-size=1024,1024 \
|
|
--virtual-time-budget=2000 \
|
|
"file://$HERE/appicon.html?v=$variant" >/dev/null 2>&1
|
|
echo " $name"
|
|
}
|
|
|
|
echo "rendering app icon ->"
|
|
render light AppIcon.png
|
|
render dark AppIcon-Dark.png
|
|
render tinted AppIcon-Tinted.png
|
|
|
|
# The light icon is the one shipped as the home-screen artwork, and iOS rejects
|
|
# an alpha channel there. The dark and tinted variants are composited by the
|
|
# system over a background it supplies, so they must keep theirs.
|
|
magick "$OUT/AppIcon.png" -background '#F8F5EF' -alpha remove -alpha off "$OUT/AppIcon.png"
|
|
|
|
echo "done"
|