alexjlockwood / avocado

🥑 Vector Drawable optimization tool 🥑
MIT License
1.35k stars 48 forks source link

Graphical errors after converting #24

Closed henningBunk closed 6 years ago

henningBunk commented 6 years ago

Hi! I optimized most of my vector drawables with this tool but had to revert it. On most devices it worked flawlessly but on one device some drawables aren't rendered correctly anymore after converting. It only happens for me on a Nexus 5 running Android 6.0.1 and a Note 3 running 5.0.

Here are two Screenshots before and after running avdo:

Before After
grafik grafik

I am guessing that the reason for it lies in the change from absolut to relative coordinates. Some other files are only rendered correctly if they aren't scaled. When the are scaled down they change similar to the example above. Maybe the

Here are the xml files:

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="48dp"
        android:height="48dp"
        android:viewportWidth="48"
        android:viewportHeight="48">

    <path
        android:fillColor="#FFFFFF"
        android:pathData="M24.05,15.49 C27.64,15.49,30.55,18.41,30.55,21.99 C30.55,23.38,30.12,24.71,29.3,25.82 L29.28,25.85 L29.26,25.88 C27.93,27.98,27.17,29.55,26.81,31.03 L21.29,31.03 C20.92,29.55,20.17,27.98,18.84,25.88 L18.82,25.85 L18.8,25.82 C17.98,24.7,17.55,23.38,17.55,21.99 C17.54,18.4,20.46,15.49,24.05,15.49 M24.05,14.28 C19.79,14.28,16.34,17.73,16.34,21.99 C16.34,23.69,16.89,25.26,17.82,26.54 C19.18,28.67,19.91,30.22,20.21,31.73 C20.27,32.03,20.53,32.25,20.84,32.25 L27.26,32.25 C27.57,32.25,27.83,32.03,27.89,31.73 C28.19,30.22,28.92,28.67,30.28,26.54 C31.21,25.26,31.76,23.69,31.76,21.99 C31.76,17.73,28.31,14.28,24.05,14.28 Z"/>

</vector>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="48dp"
        android:height="48dp"
        android:viewportWidth="48"
        android:viewportHeight="48">

    <path
        android:fillColor="#FFFFFF"
        android:pathData="M24.05 15.49c3.59 0 6.5 2.92 6.5 6.5 0 1.39-0.43 2.72-1.25 3.83l-0.02 0.03-0.02 0.03c-1.33 2.1-2.09 3.67-2.45 5.15h-5.52c-0.37-1.48-1.12-3.05-2.45-5.15l-0.02-0.03-0.02-0.03a6.429 6.429 0 0 1-1.25-3.83c-0.01-3.59 2.91-6.5 6.5-6.5m0-1.21c-4.26 0-7.71 3.45-7.71 7.71 0 1.7 0.55 3.27 1.48 4.55 1.36 2.13 2.09 3.68 2.39 5.19a0.643 0.643 0 0 0 0.63 0.52h6.42c0.31 0 0.57-0.22 0.63-0.52 0.3-1.51 1.03-3.06 2.39-5.19a7.711 7.711 0 0 0 1.48-4.55c0-4.26-3.45-7.71-7.71-7.71z"/>

</vector>

Cheers Henning

alexjlockwood commented 6 years ago

Are you using VectorDrawableCompat by any chance? I believe there is a bug that wasn't fixed until API 24 that is related to SVG arc commands... and if you use VectorDrawableCompat this bug should be fixed automatically. So I'm guessing if you use VectorDrawableCompat (which is probably recommended anyway, even if you aren't targeting pre-Lollipop devices), this bug should be fixed.

Once you confirm that, I think one possible fix on my end is to automatically approximate arcs as one or more bezier curves... which should avoid the problem.

henningBunk commented 6 years ago

Hey and thanks for the answer! No I am not using VectorDrawableCompat. I will test it tomorrow and let you know if it makes a difference.

alexjlockwood commented 6 years ago

It should fix the issue, I think. VectorDrawableCompat fixes a lot of bugs that were present in API 21-23. I think it is still something avdo should try to fix though.

On Jan 10, 2018 8:34 AM, "Henning B" notifications@github.com wrote:

Hey and thanks for the answer! No I am not using VectorDrawableCompat. I will test it tomorrow and let you know if it makes a difference.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/alexjlockwood/avdo/issues/24#issuecomment-356658108, or mute the thread https://github.com/notifications/unsubscribe-auth/ABURi1e1zkhOIhvlKB0XbIYv5aHxAHJWks5tJOaHgaJpZM4RZC-g .

alexjlockwood commented 6 years ago

I just released v0.1.5 which fixes this issue. Try it out and let me know. You can update by running

npm install -g avdo

BTW, I fixed this by making sure that avdo did not attempt to convert C commands into A commands. However, I also opened #25 which would convert all A commands into C commands in hopes of avoiding this issue entirely.

henningBunk commented 6 years ago

Awesome! Thanks for the quick fix ans explanation. Using the AppCompat fixed the problem. Updating avdo did so as well.