From 83679bd856158b838fefb3070b8adbfdb7d8ebbe Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Fri, 16 May 2025 01:33:16 +0100 Subject: [PATCH] selfdrive/assets: rasterize SVGs (#35243) * selfdrive/assets: rasterize SVGs * do entire assets dir * fixed size - 4096px is a lot * optimise them too * use inkscape * regenerate * abandon runtime svg --- selfdrive/assets/icons/checkmark.png | 3 +++ selfdrive/assets/icons/circled_check.png | 3 +++ selfdrive/assets/icons/circled_slash.png | 3 +++ selfdrive/assets/icons/close.png | 3 +++ selfdrive/assets/icons/close2.png | 3 +++ selfdrive/assets/icons/couch.png | 3 +++ .../assets/icons/disengage_on_accelerator.png | 3 +++ selfdrive/assets/icons/experimental.png | 3 +++ selfdrive/assets/icons/experimental_grey.png | 3 +++ selfdrive/assets/icons/experimental_white.png | 3 +++ selfdrive/assets/icons/eye_closed.png | 3 +++ selfdrive/assets/icons/eye_open.png | 3 +++ selfdrive/assets/icons/lock_closed.png | 3 +++ selfdrive/assets/icons/triangle.png | 3 +++ selfdrive/assets/icons/wifi_strength_full.png | 3 +++ selfdrive/assets/icons/wifi_strength_high.png | 3 +++ selfdrive/assets/icons/wifi_strength_low.png | 3 +++ .../assets/icons/wifi_strength_medium.png | 3 +++ selfdrive/assets/icons/wifi_uploading.png | 3 +++ .../images/button_continue_triangle.png | 3 +++ selfdrive/assets/prep-svg.sh | 19 ++++++++++++++++--- system/ui/lib/application.py | 9 +-------- 22 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 selfdrive/assets/icons/checkmark.png create mode 100644 selfdrive/assets/icons/circled_check.png create mode 100644 selfdrive/assets/icons/circled_slash.png create mode 100644 selfdrive/assets/icons/close.png create mode 100644 selfdrive/assets/icons/close2.png create mode 100644 selfdrive/assets/icons/couch.png create mode 100644 selfdrive/assets/icons/disengage_on_accelerator.png create mode 100644 selfdrive/assets/icons/experimental.png create mode 100644 selfdrive/assets/icons/experimental_grey.png create mode 100644 selfdrive/assets/icons/experimental_white.png create mode 100644 selfdrive/assets/icons/eye_closed.png create mode 100644 selfdrive/assets/icons/eye_open.png create mode 100644 selfdrive/assets/icons/lock_closed.png create mode 100644 selfdrive/assets/icons/triangle.png create mode 100644 selfdrive/assets/icons/wifi_strength_full.png create mode 100644 selfdrive/assets/icons/wifi_strength_high.png create mode 100644 selfdrive/assets/icons/wifi_strength_low.png create mode 100644 selfdrive/assets/icons/wifi_strength_medium.png create mode 100644 selfdrive/assets/icons/wifi_uploading.png create mode 100644 selfdrive/assets/images/button_continue_triangle.png diff --git a/selfdrive/assets/icons/checkmark.png b/selfdrive/assets/icons/checkmark.png new file mode 100644 index 0000000000..0f9a802a35 --- /dev/null +++ b/selfdrive/assets/icons/checkmark.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc472f0e575e314c4006cb6e9845fb9fb9a13cf08fe74fbe1593dee53c20d977 +size 4329 diff --git a/selfdrive/assets/icons/circled_check.png b/selfdrive/assets/icons/circled_check.png new file mode 100644 index 0000000000..7611bc821f --- /dev/null +++ b/selfdrive/assets/icons/circled_check.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fdb0be280ac3a78bf95f5b92fafe94de5084ecc06836459c3a9fe1912a5b2454 +size 10479 diff --git a/selfdrive/assets/icons/circled_slash.png b/selfdrive/assets/icons/circled_slash.png new file mode 100644 index 0000000000..74a9b342f6 --- /dev/null +++ b/selfdrive/assets/icons/circled_slash.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2a992a83eaa87762e12dc226f36af48e1cdbfc3b83ef75b6a2fc4103e3697a0 +size 9120 diff --git a/selfdrive/assets/icons/close.png b/selfdrive/assets/icons/close.png new file mode 100644 index 0000000000..66d1545632 --- /dev/null +++ b/selfdrive/assets/icons/close.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c11f831c17080a8ffaa8469cf91a079a4abfb72e5238afe02b92bceb3442db0 +size 2656 diff --git a/selfdrive/assets/icons/close2.png b/selfdrive/assets/icons/close2.png new file mode 100644 index 0000000000..4497c97547 --- /dev/null +++ b/selfdrive/assets/icons/close2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cbfed12ddb5731b7b568539fe59f382356b46fdd146a9e0a1b768d3e5efd0378 +size 4350 diff --git a/selfdrive/assets/icons/couch.png b/selfdrive/assets/icons/couch.png new file mode 100644 index 0000000000..677ad0f9ee --- /dev/null +++ b/selfdrive/assets/icons/couch.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:911f59f248015600da7ecc689398103d47dfc57f6be17ac8c8e543a726a6c64b +size 3311 diff --git a/selfdrive/assets/icons/disengage_on_accelerator.png b/selfdrive/assets/icons/disengage_on_accelerator.png new file mode 100644 index 0000000000..4134834448 --- /dev/null +++ b/selfdrive/assets/icons/disengage_on_accelerator.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f23fabbf60fff6ef88ba6f27f2775b1ae6be172a994e41267983a9ec0f984bfc +size 15059 diff --git a/selfdrive/assets/icons/experimental.png b/selfdrive/assets/icons/experimental.png new file mode 100644 index 0000000000..2332fe11d0 --- /dev/null +++ b/selfdrive/assets/icons/experimental.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1e58deb1778cf2826339f27e9f09eecc79ea137c1436210c14b71c352a649c77 +size 34953 diff --git a/selfdrive/assets/icons/experimental_grey.png b/selfdrive/assets/icons/experimental_grey.png new file mode 100644 index 0000000000..058c3e1358 --- /dev/null +++ b/selfdrive/assets/icons/experimental_grey.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f37a02dd914405c6f86f415700dd5985eb976b923e7abd6580d2da76533594e +size 9466 diff --git a/selfdrive/assets/icons/experimental_white.png b/selfdrive/assets/icons/experimental_white.png new file mode 100644 index 0000000000..6a9cfc4407 --- /dev/null +++ b/selfdrive/assets/icons/experimental_white.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b2dad33fead9f064c3a548651d6ef37daf82b6127c329683f538ec6e986ecbc +size 11204 diff --git a/selfdrive/assets/icons/eye_closed.png b/selfdrive/assets/icons/eye_closed.png new file mode 100644 index 0000000000..8eba02e600 --- /dev/null +++ b/selfdrive/assets/icons/eye_closed.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:64d9dc106172d3a54088ef51a27a48145154ca040c43ecbc8d626fa42e38886e +size 9352 diff --git a/selfdrive/assets/icons/eye_open.png b/selfdrive/assets/icons/eye_open.png new file mode 100644 index 0000000000..9783716ff3 --- /dev/null +++ b/selfdrive/assets/icons/eye_open.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94246db66e774cbaee618931f76ecc38ecb72eca097d1e6c20a8dec2a5f8cd29 +size 7087 diff --git a/selfdrive/assets/icons/lock_closed.png b/selfdrive/assets/icons/lock_closed.png new file mode 100644 index 0000000000..21e6795737 --- /dev/null +++ b/selfdrive/assets/icons/lock_closed.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b89b8803bb610515aef051c93b833dc62f8c847558873cfd50a0b240c968449 +size 4911 diff --git a/selfdrive/assets/icons/triangle.png b/selfdrive/assets/icons/triangle.png new file mode 100644 index 0000000000..47ff24f200 --- /dev/null +++ b/selfdrive/assets/icons/triangle.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5f2745ce89c926e507888ea7c6df1884aab045887048cf0d813407396a2e6b18 +size 5894 diff --git a/selfdrive/assets/icons/wifi_strength_full.png b/selfdrive/assets/icons/wifi_strength_full.png new file mode 100644 index 0000000000..1a710f2967 --- /dev/null +++ b/selfdrive/assets/icons/wifi_strength_full.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8b7f0971cf612b905ccb338e40921932773538517fc9f0f7a4a847ad596287a9 +size 7171 diff --git a/selfdrive/assets/icons/wifi_strength_high.png b/selfdrive/assets/icons/wifi_strength_high.png new file mode 100644 index 0000000000..2d360968b6 --- /dev/null +++ b/selfdrive/assets/icons/wifi_strength_high.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a2afacf302bcdc3f5e0d2f734508e8fea6f803813098d52fa6b878c765ba7a58 +size 9360 diff --git a/selfdrive/assets/icons/wifi_strength_low.png b/selfdrive/assets/icons/wifi_strength_low.png new file mode 100644 index 0000000000..d016528304 --- /dev/null +++ b/selfdrive/assets/icons/wifi_strength_low.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7dfe50815c76d459dc104ce4a5e4b5dfd882e11b65e07706cacd336e69e788f4 +size 9756 diff --git a/selfdrive/assets/icons/wifi_strength_medium.png b/selfdrive/assets/icons/wifi_strength_medium.png new file mode 100644 index 0000000000..9c943543a4 --- /dev/null +++ b/selfdrive/assets/icons/wifi_strength_medium.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:304ab97ac9724a7a133a36c2d14da9fe8ab660c9a29abb99cc0a4828f94d8801 +size 9627 diff --git a/selfdrive/assets/icons/wifi_uploading.png b/selfdrive/assets/icons/wifi_uploading.png new file mode 100644 index 0000000000..19d9bf36ce --- /dev/null +++ b/selfdrive/assets/icons/wifi_uploading.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8eac201013322db1580649a253da7ae38eb9f16f6089234e769b746951e874ee +size 7171 diff --git a/selfdrive/assets/images/button_continue_triangle.png b/selfdrive/assets/images/button_continue_triangle.png new file mode 100644 index 0000000000..c56e112094 --- /dev/null +++ b/selfdrive/assets/images/button_continue_triangle.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9218e02c42b0f80858477255e24a97da4cf0b2898fc76f3806409d65b104668 +size 4510 diff --git a/selfdrive/assets/prep-svg.sh b/selfdrive/assets/prep-svg.sh index 44afa369c1..661464a5c6 100755 --- a/selfdrive/assets/prep-svg.sh +++ b/selfdrive/assets/prep-svg.sh @@ -1,10 +1,23 @@ #!/usr/bin/env bash set -e -for svg in $(find icons/ images/ -type f | grep svg$); do +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + +# sudo apt install inkscape + +for svg in $(find $DIR -type f | grep svg$); do bunx svgo $svg --multipass --pretty --indent 2 # convert to PNG - # sudo apt install inkscape - convert -background none -resize 400% -density 384 $svg "${svg%.svg}.png" + png="${svg%.svg}.png" + width=$(inkscape --query-width "$svg") + height=$(inkscape --query-height "$svg") + if (( $(echo "$width > $height" | bc -l) )); then + export_dim="--export-width=512" + else + export_dim="--export-height=512" + fi + inkscape "$svg" --export-filename="$png" $export_dim + + optipng -o7 -strip all "$png" done diff --git a/system/ui/lib/application.py b/system/ui/lib/application.py index fb7f7832a4..8961bb0327 100644 --- a/system/ui/lib/application.py +++ b/system/ui/lib/application.py @@ -80,10 +80,7 @@ class GuiApplication: def _load_texture_from_image(self, image_path: str, width: int, height: int, alpha_premultiply = False, keep_aspect_ratio=True): """Load and resize a texture, storing it for later automatic unloading.""" - if image_path.endswith('.svg'): - image = self._load_image_from_svg(image_path) - else: - image = rl.load_image(image_path) + image = rl.load_image(image_path) if alpha_premultiply: rl.image_alpha_premultiply(image) @@ -112,10 +109,6 @@ class GuiApplication: rl.unload_image(image) return texture - def _load_image_from_svg(self, svg_path: str): - # TODO: Implement SVG loading - assert(0) - def close(self): if not rl.is_window_ready(): return