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

setMatrix method for the CircularProgressBar #74

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

mesropd
Copy link

@mesropd mesropd commented Mar 31, 2015

Add setMatrix(Matrix) method for the CircularProgressBar, for better quality use software layer.
This example snippet sets isometric matrix on the CircularProgressBar.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
...
circularProgressBar.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                Matrix matrix = getIsometricMatrix(circularProgressBar.getWidth(), circularProgressBar.getHeight());
                circularProgressBar.setMatrix(matrix);
                circularProgressBar.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }
        });
...
}

public static Matrix getIsometricMatrix(float w, float h) {
    Matrix matrix = new Matrix();
    final float pX = w / 2f;
    final float pY = h / 2f;
    final Camera camera = new Camera();
    camera.save();
    camera.rotateX(45);
    camera.rotateY(0);
    camera.rotateZ(0);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-pX,-pY);
    matrix.postTranslate(pX,pY);
    float sX = 1.0f;
    float sY = 1.0f;
    matrix.postScale(sX,sY);
    final float sPX =-(pX / w) * ((sX * w) - w);
    final float sPY =-(pY / h) * ((sY * h) - h);
    matrix.postTranslate(sPX,sPY);
    return matrix;
}

0078756c-d71a-11e4-98d3-844bd14bdf5f

@castorflex castorflex force-pushed the dev branch 4 times, most recently from 6c545ed to 8234af5 Compare September 12, 2015 15:29
@castorflex castorflex force-pushed the dev branch 3 times, most recently from 7b6b0d9 to 12604cc Compare June 27, 2017 19:34
@castorflex castorflex force-pushed the dev branch 6 times, most recently from 098b430 to 70853d9 Compare May 21, 2021 17:07
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

Successfully merging this pull request may close these issues.

1 participant