#!/usr/bin/env bash # generate-assets.sh — Generate FiberOps PNG assets from SVG sources # # Requirements (install one): # brew install inkscape (macOS / Linux) # brew install librsvg (lighter: rsvg-convert) # apt-get install librsvg2-bin (Debian/Ubuntu) # # Usage: # ./scripts/generate-assets.sh # # Output: assets/*.png (overwrites existing files) set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" ASSETS="$REPO_ROOT/assets" SVGS="$SCRIPT_DIR/svg" # --------------------------------------------------------------------------- # Check for a suitable SVG renderer # --------------------------------------------------------------------------- if command -v inkscape &>/dev/null; then RENDERER="inkscape" elif command -v rsvg-convert &>/dev/null; then RENDERER="rsvg" else echo "ERROR: Install inkscape or librsvg (rsvg-convert) first." >&2 echo " macOS: brew install inkscape OR brew install librsvg" >&2 echo " Linux: apt-get install inkscape OR apt-get install librsvg2-bin" >&2 exit 1 fi export_png() { local svg="$1" out="$2" w="$3" h="$4" echo " → $out (${w}×${h})" if [[ "$RENDERER" == "inkscape" ]]; then inkscape --export-type=png \ --export-filename="$out" \ --export-width="$w" \ --export-height="$h" \ "$svg" 2>/dev/null else rsvg-convert -w "$w" -h "$h" -o "$out" "$svg" fi } mkdir -p "$SVGS" # --------------------------------------------------------------------------- # Inline SVG sources (written to scripts/svg/ so they can be edited) # --------------------------------------------------------------------------- # 1. icon-bg.svg — opaque cyan square with "FO" (used for icon.png) cat > "$SVGS/icon-bg.svg" <<'SVG' FO SVG # 2. icon-fg.svg — transparent background, white "FO" (adaptive icon foreground) cat > "$SVGS/icon-fg.svg" <<'SVG' FO SVG # 3. splash.svg — transparent, centered logo for splash (composited over #F8FAFC) cat > "$SVGS/splash.svg" <<'SVG' FO FiberOps SVG # 4. favicon.svg — tiny "F" on cyan cat > "$SVGS/favicon.svg" <<'SVG' F SVG # 5. monochrome.svg — white "FO" on transparent (Android 13 themed icon) cat > "$SVGS/monochrome.svg" <<'SVG' FO SVG # --------------------------------------------------------------------------- # Export PNGs # --------------------------------------------------------------------------- echo "Exporting PNGs..." export_png "$SVGS/icon-bg.svg" "$ASSETS/icon.png" 1024 1024 export_png "$SVGS/icon-fg.svg" "$ASSETS/adaptive-icon.png" 1024 1024 export_png "$SVGS/icon-fg.svg" "$ASSETS/android-icon-foreground.png" 1024 1024 export_png "$SVGS/icon-bg.svg" "$ASSETS/android-icon-background.png" 1024 1024 export_png "$SVGS/monochrome.svg" "$ASSETS/android-icon-monochrome.png" 1024 1024 export_png "$SVGS/splash.svg" "$ASSETS/splash-icon.png" 1024 1024 export_png "$SVGS/favicon.svg" "$ASSETS/favicon.png" 48 48 echo "" echo "Done. Files written to assets/" echo "Verify with: ls -lh assets/*.png"