Created
February 6, 2019 10:31
-
-
Save sbliven/7287fa4f37d8abdcfe757a3813f8e6cd to your computer and use it in GitHub Desktop.
Generate evenly-spaced heic file for testing Mac dynamic wallpapers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
JSONFILE="${1:-wallpapper.json}" | |
HEICFILE="${2:-wallpapper.heic}" | |
blocks=() | |
for ((a=-90;a<=90;a+=10)); do | |
for ((z=0; z<360; z+=10)); do | |
f="test_${a}_${z}.png" | |
# Create image | |
convert -background lightblue -fill blue \ | |
-pointsize 128 -font "Chalkduster" \ | |
-size 2880x1800 -gravity center \ | |
label:"Elevation:$a\nAzimuth:$z" "$f" | |
if [[ a == 0 && z == 0 ]]; then | |
primary=true | |
else | |
primary=false | |
fi | |
if [[ a < 0 ]]; then | |
isForLight=true | |
isForDark=false | |
else | |
isForLight=false | |
isForDark=true | |
fi | |
IFS='' read -r -d '' BLOCK <<END || true | |
{ | |
"fileName": "$f", | |
"isPrimary": $primary, | |
"isForLight": $isForLight, | |
"isForDark": $isForDark, | |
"altitude": $a, | |
"azimuth": $z | |
} | |
END | |
blocks+=("$BLOCK") | |
done | |
done | |
{ | |
echo "[" | |
echo -n "${blocks[0]}" | |
for ((i=1;i<"${#blocks[@]}";i++)); do | |
echo -n ",${blocks[$i]}" | |
done | |
echo "]" | |
} > "$JSONFILE" | |
/usr/local/bin/wallpapper -i "$JSONFILE" -o "$HEICFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment