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

Multiply path scale problem #14

Open
MikkiMouse opened this issue May 2, 2018 · 1 comment
Open

Multiply path scale problem #14

MikkiMouse opened this issue May 2, 2018 · 1 comment

Comments

@MikkiMouse
Copy link

Hi, I have a vector image (vector_img.xml):

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

    <path
        android:fillColor="#FF000000"
        android:pathData="M 150 0 C 232.842712475 0 300 67.1572875254 300 150 C 300 232.842712475 232.842712475 300 150 300 C 67.1572875254 300 0 232.842712475 0 150 C 0 67.1572875254 67.1572875254 0 150 0 Z" />

    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M 150 30 C 216.27416998 30 270 83.7258300203 270 150 C 270 216.27416998 216.27416998 270 150 270 C 83.7258300203 270 30 216.27416998 30 150 C 30 83.7258300203 83.7258300203 30 150 30 Z" />

    <path
        android:fillColor="#FF000000"
        android:pathData="M 150 60 C 199.705627485 60 240 100.294372515 240 150 C 240 199.705627485 199.705627485 240 150 240 C 100.294372515 240 60 199.705627485 60 150 C 60 100.294372515 100.294372515 60 150 60 Z" />

</vector>

I'm trying to scale vector programmatically like this:

VectorMasterDrawable vectorDrawable = new VectorMasterDrawable(context, R.drawable.vector_img);
vectorDrawable.setScaleX(1.5f);
vectorDrawable.setScaleY(1.5f);

The result is not happy:

from

Perhaps the problem is that when we scale vector we can't set pivot points? Or am I doing something wrong?)

Thanks

@harjot-oberai
Copy link
Owner

Yes, the problem is with the pivot points being at the top left corner by default.

I will implement another scale method which takes pivot points as arguments along with the scale factor.

Thanks for opening the issue.

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

No branches or pull requests

2 participants