8000 selfdrive/assets: rasterize SVGs by incognitojam · Pull Request #35243 · commaai/openpilot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

selfdrive/assets: rasterize SVGs #35243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/checkmark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/circled_check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/circled_slash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/close2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/couch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/disengage_on_accelerator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/experimental.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/experimental_grey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/experimental_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/eye_closed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/eye_open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/lock_closed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/triangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/wifi_strength_full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/wifi_strength_high.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/wifi_strength_low.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/wifi_strength_medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/icons/wifi_uploading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions selfdrive/assets/images/button_continue_triangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 16 additions & 3 deletions selfdrive/assets/prep-svg.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 1 addition & 8 deletions system/ui/lib/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ def texture(self, asset_path: str, width: int, height: int, alpha_premultiply=Fa

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)
Expand Down Expand Up @@ -112,10 +109,6 @@ def _load_texture_from_image(self, image_path: str, width: int, height: int, alp
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
Expand Down
Loading
0