| 1 | #!/bin/sh |
| 2 | # make_pngs.sh regenerates the bundled PNGs in assets/icons from the SVG |
| 3 | # sources in scripts/icons. assets/ is what ships — CI zips it beside the |
| 4 | # binary and vab packages it into the APK whole — so its tree stays |
| 5 | # runtime-only: the sources live beside this script, and nothing but the |
| 6 | # PNGs ends up bundled. |
| 7 | # |
| 8 | # Each entry maps one source SVG (its export name found by prefix; Google's |
| 9 | # export names churn with every fill/weight change) to the PNG name the |
| 10 | # widget's buttons draw — the role, spelled in libvendetta/draw.v as |
| 11 | # strip_icon_names — and the colour the role draws with in the compiled-in |
| 12 | # vinix-dark palette (text_main, #ffffff, for every strip icon today). The |
| 13 | # colour step exists because the exports carry their own #e3e3e3 fill: raster |
| 14 | # colorization makes the bundle conform to the palette no matter what colour |
| 15 | # the export tool is pointed at. The page_ entries are the settings dialog's |
| 16 | # navigation, in the palette's text_muted. |
| 17 | # |
| 18 | # ImageMagick is the rasterizer for now; it renders the 24 px viewBox |
| 19 | # straight at 64 px (density 96 * 64/24 = 256), which is what the buttons and |
| 20 | # their 2x ui scale need. Swap the tool at the `one` function below if the |
| 21 | # rasterizer changes; the role and colour tables remain the stable part. |
| 22 | set -eu |
| 23 | |
| 24 | here=$(cd "$(dirname "$0")" && pwd) |
| 25 | svg_dir="$here/icons" |
| 26 | out_dir="$here/../assets/icons" |
| 27 | |
| 28 | entries='play_arrow play #ffffff |
| 29 | pause pause #ffffff |
| 30 | replay_30 replay30 #ffffff |
| 31 | forward_30 forward30 #ffffff |
| 32 | volume_up volume_up #ffffff |
| 33 | volume_mute volume_mute #ffffff |
| 34 | volume_off volume_off #ffffff |
| 35 | tune page_interface #e2e8f0 |
| 36 | palette page_appearance #e2e8f0 |
| 37 | play_circle page_playback #e2e8f0 |
| 38 | movie page_video #e2e8f0 |
| 39 | equalizer page_audio #e2e8f0 |
| 40 | subtitles page_subtitles #e2e8f0 |
| 41 | settings page_advanced #e2e8f0' |
| 42 | |
| 43 | if command -v magick >/dev/null 2>&1; then |
| 44 | rasterizer=magick |
| 45 | elif command -v convert >/dev/null 2>&1; then |
| 46 | rasterizer=convert |
| 47 | else |
| 48 | echo 'make_pngs: ImageMagick is missing: install magick (or convert) or replace it in one() here' >&2 |
| 49 | exit 1 |
| 50 | fi |
| 51 | |
| 52 | one() { |
| 53 | # one <svg-prefix> <png-name> <colour>: raster at 64 px from the SVG's 24 |
| 54 | # px viewBox, colourize the raster to the palette colour keeping alpha, |
| 55 | # and strip the export metadata the PNG bundle does not carry. |
| 56 | svg=$(ls "$svg_dir/${1}"_24dp_*.svg 2>/dev/null | head -n 1) |
| 57 | if [ -z "$svg" ]; then |
| 58 | echo "make_pngs: no *_24dp_*.svg match for prefix ${1} under ${svg_dir}" >&2 |
| 59 | exit 1 |
| 60 | fi |
| 61 | $rasterizer -background none -density 256 "$svg" \ |
| 62 | -fill "$3" -colorize 100 -strip "$out_dir/$2.png" |
| 63 | } |
| 64 | |
| 65 | mkdir -p "$out_dir" |
| 66 | echo "$entries" | while read -r prefix png colour; do |
| 67 | [ -z "$prefix" ] && continue |
| 68 | one "$prefix" "$png" "$colour" |
| 69 | done |
| 70 | |
| 71 | echo 'make_pngs: bundle refreshed' |
| 72 | |