Skip to content
Snippets Groups Projects
Select Git revision
  • a9bb2ca25914d73fc614062042ab40fc02737712
  • master default protected
  • 39-upgrade-framework-and-dependencies
  • 22-improve-app-metadata
  • 9-improve-layout-and-graphics
  • Release_0.9.0_34 protected
  • Release_0.8.2_33 protected
  • Release_0.8.1_32 protected
  • Release_0.8.0_31 protected
  • Release_0.7.0_30 protected
  • Release_0.6.0_29 protected
  • Release_0.5.0_28 protected
  • Release_0.4.2_27 protected
  • Release_0.4.1_26 protected
  • Release_0.4.0_25 protected
  • Release_0.3.1_24 protected
  • Release_0.3.0_23 protected
  • Release_0.2.1_22 protected
  • Release_0.2.0_21 protected
  • Release_0.1.1_20 protected
  • Release_0.1.0_19 protected
  • Release_0.0.18_18 protected
  • Release_0.0.17_17 protected
  • Release_0.0.16_16 protected
  • Release_0.0.15_15 protected
25 results

build_game_icons.sh

Blame
  • build_application_icons.sh 2.28 KiB
    #! /bin/bash
    
    # Check dependencies
    command -v inkscape >/dev/null 2>&1 || { echo >&2 "I require inkscape but it's not installed. Aborting."; exit 1; }
    command -v scour >/dev/null 2>&1 || { echo >&2 "I require scour but it's not installed. Aborting."; exit 1; }
    command -v optipng >/dev/null 2>&1 || { echo >&2 "I require optipng but it's not installed. Aborting."; exit 1; }
    
    CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
    BASE_DIR="$(dirname "${CURRENT_DIR}")"
    
    SOURCE="${CURRENT_DIR}/icon.svg"
    OPTIPNG_OPTIONS="-preserve -quiet -o7"
    
    # optimize svg
    cp ${SOURCE} ${SOURCE}.tmp
    scour \
        --remove-descriptive-elements \
        --enable-id-stripping \
        --enable-viewboxing \
        --enable-comment-stripping \
        --nindent=4 \
        -i ${SOURCE}.tmp \
        -o ${SOURCE}
    rm ${SOURCE}.tmp
    
    # build icons
    function build_icon() {
      ICON_SIZE="$1"
      TARGET="$2"
    
      TARGET_PNG="${TARGET}.png"
    
      inkscape \
          --export-width=${ICON_SIZE} \
          --export-height=${ICON_SIZE} \
          --export-filename=${TARGET_PNG} \
          ${SOURCE}
    
      optipng ${OPTIPNG_OPTIONS} ${TARGET_PNG}
    }
    
    # build fastlane image
    function build_fastlane_image() {
      WIDTH="$1"
      HEIGHT="$2"
      TARGET="$3"
    
      SOURCE_FASTLANE="${CURRENT_DIR}/featureGraphic.svg"
    
      cp ${SOURCE_FASTLANE} ${SOURCE_FASTLANE}.tmp
      scour \
          --remove-descriptive-elements \
          --enable-id-stripping \
          --enable-viewboxing \
          --enable-comment-stripping \
          --nindent=4 \
          -i ${SOURCE_FASTLANE}.tmp \
          -o ${SOURCE_FASTLANE}
      rm ${SOURCE_FASTLANE}.tmp
    
      TARGET_PNG="${TARGET}.png"
    
      inkscape \
          --export-width=${WIDTH} \
          --export-height=${HEIGHT} \
          --export-filename=${TARGET_PNG} \
          ${SOURCE_FASTLANE}
    
      optipng ${OPTIPNG_OPTIONS} ${TARGET_PNG}
    }
    
    build_icon  72 ${BASE_DIR}/android/app/src/main/res/mipmap-hdpi/ic_launcher
    build_icon  48 ${BASE_DIR}/android/app/src/main/res/mipmap-mdpi/ic_launcher
    build_icon  96 ${BASE_DIR}/android/app/src/main/res/mipmap-xhdpi/ic_launcher
    build_icon 144 ${BASE_DIR}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher
    build_icon 192 ${BASE_DIR}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher
    build_icon 512 ${BASE_DIR}/fastlane/metadata/android/en-US/images/icon
    
    build_fastlane_image 1024 500 ${BASE_DIR}/fastlane/metadata/android/en-US/images/featureGraphic