Skip to content
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

Android: Avoid long path data #29

Open
pocmo opened this issue Jul 10, 2018 · 2 comments
Open

Android: Avoid long path data #29

pocmo opened this issue Jul 10, 2018 · 2 comments

Comments

@pocmo
Copy link

pocmo commented Jul 10, 2018

I imported this SVG:
https://github.com/FirefoxUX/photon-icons/blob/master/icons/android/pin-outline-24.svg

Android Studio complains that it uses a very long vector path (1085 characters) and that this is bad for performance.

Imported path:

android:pathData="M12.617 2.076a1 1 0 0 1 1.09 0.217 l8 8A1 1 0 0 1 21 12c-1.034 0-1.886 0.007 -2.6 0.212 -0.647 0.184 -1.149 0.522 -1.506 1.235-0.189 0.378 -0.293 0.773 -0.379 1.247-0.026 0.144 -0.053 0.314 -0.082 0.5 -0.057 0.357 -0.123 0.77 -0.207 1.148-0.288 1.297-0.875 2.721-2.519 4.365a1 1 0 0 1-1.414 0L8.5 16.914l-4.793 4.793a1 1 0 1 1-1.414-1.414L7.086 15.5l-3.793-3.793a1 1 0 0 1 0-1.414c1.644-1.644 3.068-2.23 4.365-2.52 0.378 -0.083 0.79 -0.149 1.149-0.206 0.185 -0.029 0.355 -0.056 0.498 -0.082 0.475 -0.086 0.87 -0.19 1.248-0.38 0.713 -0.356 1.05-0.858 1.235-1.505 0.205 -0.715 0.212 -1.566 0.212 -2.6a1 1 0 0 1 0.617-0.924zm1.272 3.227a6.37 6.37 0 0 1-0.178 0.847 c-0.315 1.103-0.977 2.101-2.264 2.744-0.622 0.311 -1.227 0.457 -1.784 0.559 a25.29 25.29 0 0 1-0.651 0.108 13.86 13.86 0 0 0-0.92 0.165 c-0.772 0.172 -1.626 0.476 -2.644 1.308l7.518 7.518c0.832-1.018 1.136-1.872 1.308-2.644 0.074 -0.333 0.118 -0.615 0.166 -0.92 0.03 -0.2 0.064 -0.41 0.107 -0.651 0.102 -0.557 0.248 -1.162 0.559 -1.784 0.643 -1.287 1.641-1.95 2.744-2.265 0.276 -0.078 0.56 -0.136 0.847 -0.177l-4.808-4.808z"

For some reason the previous version (not mirrored) in our repo was much smaller. But I do not remember how/if I optimized it:

android:pathData="M12.617 2.076a1 1 0 0 1 1.09 0.217 l8 8A1 1 0 0 1 21 12c-1.034 0-1.886 0.007 -2.6 0.212 -0.647 0.184 -1.149 0.522 -1.506 1.235-0.189 0.378 -0.293 0.773 -0.379 1.247-0.026 0.144 -0.053 0.314 -0.082 0.5 -0.057 0.357 -0.123 0.77 -0.207 1.148-0.288 1.297-0.875 2.721-2.519 4.365a1 1 0 0 1-1.414 0L8.5 16.914l-4.793 4.793a1 1 0 1 1-1.414-1.414L7.086 15.5l-3.793-3.793a1 1 0 0 1 0-1.414c1.644-1.644 3.068-2.23 4.365-2.52 0.378 -0.083 0.79 -0.149 1.149-0.206 0.185 -0.029 0.355 -0.056 0.498 -0.082 0.475 -0.086 0.87 -0.19 1.248-0.38 0.713 -0.356 1.05-0.858 1.235-1.505 0.205 -0.715 0.212 -1.566 0.212 -2.6a1 1 0 0 1 0.617-0.924z"

@pocmo
Copy link
Author

pocmo commented Jul 10, 2018

I was able to reduce the new version to:

android:pathData="M12.62 2.08a1 1 0 0 1 1.09 0.21l8 8A1 1 0 0 1 21 12c-1.03 0-1.89 0-2.6 0.21a2.24 2.24 0 0 0-1.5 1.24 4.5 4.5 0 0 0-0.39 1.24 8.47 8.47 0 0 1-2.8 6.01 1 1 0 0 1-1.42 0L8.5 16.92l-4.8 4.8a1 1 0 1 1-1.4-1.42l4.79-4.79-3.8-3.8a1 1 0 0 1 0-1.4 8.5 8.5 0 0 1 4.37-2.53A20.42 20.42 0 0 1 9.3 7.5a4.46 4.46 0 0 0 1.25-0.38A2.24 2.24 0 0 0 11.8 5.6 9.82 9.82 0 0 0 12 3a1 1 0 0 1 0.62-0.92zm1.27 3.22a6.37 6.37 0 0 1-0.18 0.85 4.23 4.23 0 0 1-2.26 2.74 6.49 6.49 0 0 1-1.79 0.56 25.29 25.29 0 0 1-0.65 0.11A13.86 13.86 0 0 0 8.1 9.73a6 6 0 0 0-2.64 1.3l7.52 7.52a6 6 0 0 0 1.3-2.64c0.08-0.34 0.12-0.62 0.17-0.92a23.43 23.43 0 0 1 0.1-0.65 6.49 6.49 0 0 1 0.57-1.79 4.23 4.23 0 0 1 2.74-2.26 6.5 6.5 0 0 1 0.85-0.18l-4.81-4.8z"

@aminalhazwani
Copy link
Collaborator

@bwinton can you help us and look into this? Thank you thank you 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants