#!/bin/sh # make_pngs.sh regenerates the bundled PNGs in assets/icons from the SVG # sources in scripts/icons. assets/ is what ships — CI zips it beside the # binary and vab packages it into the APK whole — so its tree stays # runtime-only: the sources live beside this script, and nothing but the # PNGs ends up bundled. # # Each entry maps one source SVG (its export name found by prefix; Google's # export names churn with every fill/weight change) to the PNG name the # widget's buttons draw — the role, spelled in libvendetta/draw.v as # strip_icon_names — and the colour the role draws with in the compiled-in # vinix-dark palette (text_main, #ffffff, for every strip icon today). The # colour step exists because the exports carry their own #e3e3e3 fill: raster # colorization makes the bundle conform to the palette no matter what colour # the export tool is pointed at. The page_ entries are the settings dialog's # navigation, in the palette's text_muted. # # ImageMagick is the rasterizer for now; it renders the 24 px viewBox # straight at 64 px (density 96 * 64/24 = 256), which is what the buttons and # their 2x ui scale need. Swap the tool at the `one` function below if the # rasterizer changes; the role and colour tables remain the stable part. set -eu here=$(cd "$(dirname "$0")" && pwd) svg_dir="$here/icons" out_dir="$here/../assets/icons" entries='play_arrow play #ffffff pause pause #ffffff replay_30 replay30 #ffffff forward_30 forward30 #ffffff volume_up volume_up #ffffff volume_mute volume_mute #ffffff volume_off volume_off #ffffff tune page_interface #e2e8f0 palette page_appearance #e2e8f0 play_circle page_playback #e2e8f0 movie page_video #e2e8f0 equalizer page_audio #e2e8f0 subtitles page_subtitles #e2e8f0 settings page_advanced #e2e8f0' if command -v magick >/dev/null 2>&1; then rasterizer=magick elif command -v convert >/dev/null 2>&1; then rasterizer=convert else echo 'make_pngs: ImageMagick is missing: install magick (or convert) or replace it in one() here' >&2 exit 1 fi one() { # one : raster at 64 px from the SVG's 24 # px viewBox, colourize the raster to the palette colour keeping alpha, # and strip the export metadata the PNG bundle does not carry. svg=$(ls "$svg_dir/${1}"_24dp_*.svg 2>/dev/null | head -n 1) if [ -z "$svg" ]; then echo "make_pngs: no *_24dp_*.svg match for prefix ${1} under ${svg_dir}" >&2 exit 1 fi $rasterizer -background none -density 256 "$svg" \ -fill "$3" -colorize 100 -strip "$out_dir/$2.png" } mkdir -p "$out_dir" echo "$entries" | while read -r prefix png colour; do [ -z "$prefix" ] && continue one "$prefix" "$png" "$colour" done echo 'make_pngs: bundle refreshed'