Java Code Examples for android.graphics.Camera#rotateX()

The following examples show how to use android.graphics.Camera#rotateX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YAxisAnimation.java    From appcan-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected final void applyTransformation(float paramFloat, Transformation transformation) {
    float f1 = 0.0F - 360.0F * paramFloat;
    float f2 = mWidth;
    float f3 = mHeight;
    final Camera camera = mCamera;
    Matrix matrix = transformation.getMatrix();
    camera.save();
    if ((0x1 & mRotationFlags) == 1)
        camera.rotateX(f1);
    if ((0x2 & mRotationFlags) == 2)
        camera.rotateY(f1);
    if ((0x4 & mRotationFlags) == 4)
        camera.rotateZ(f1);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-f2, -f3);
    matrix.postTranslate(f2, f3);
}
 
Example 2
Source File: RotationDrawStrategy.java    From styT with Apache License 2.0 6 votes vote down vote up
/**
 * 根据角度绘制图标的类
 * @param canvas 画布
 * @param fraction 完成时间百分比
 * @param icon 图标
 * @param width view宽度
 * @param height view高度
 */
private void drawIconOne(Canvas canvas, float fraction, Bitmap icon, int width, int height) {
    Camera camera = new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    canvas.save();
    int centerX = width / 2;
    int centerY = height / 2 - 200;
    int x = centerX - icon.getWidth()/2;
    int y = centerY - icon.getHeight()/2;
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);
    canvas.concat(matrix);
    canvas.clipRect(x, y, x + icon.getWidth() * fraction * 0.5f, y + icon.getHeight() * fraction * 0.5f);
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180);
    camera.rotateY(-180);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();
}
 
Example 3
Source File: AutoTextView.java    From NewXmPluginSDK with Apache License 2.0 6 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float fromDegrees = mFromDegrees;
    float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);

    final float centerX = mCenterX;
    final float centerY = mCenterY;
    final Camera camera = mCamera;
    final int derection = mTurnUp ? 1 : -1;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mTurnIn) {
        camera.translate(0.0f, derection * mCenterY * (interpolatedTime - 1.0f), 0.0f);
    } else {
        camera.translate(0.0f, derection * mCenterY * (interpolatedTime), 0.0f);
    }
    camera.rotateX(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
 
Example 4
Source File: RotationDrawStrategy.java    From youqu_master with Apache License 2.0 6 votes vote down vote up
/**
 * 根据角度绘制图标的类
 * @param canvas 画布
 * @param fraction 完成时间百分比
 * @param icon 图标
 * @param width view宽度
 * @param height view高度
 */
private void drawIconOne(Canvas canvas, float fraction, Bitmap icon, int width, int height) {
    Camera camera = new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    canvas.save();
    int centerX = width / 2;
    int centerY = height / 2 - 200;
    int x = centerX - icon.getWidth()/2;
    int y = centerY - icon.getHeight()/2;
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);
    canvas.concat(matrix);
    canvas.clipRect(x, y, x + icon.getWidth() * fraction * 0.5f, y + icon.getHeight() * fraction * 0.5f);
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180);
    camera.rotateY(-180);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();
}
 
Example 5
Source File: RotationDrawStrategy.java    From FancyView with Apache License 2.0 5 votes vote down vote up
/**
 * 根据角度绘制图标的类
 * @param canvas 画布
 * @param degree 角度
 * @param icon 图标
 * @param width view宽度
 * @param height view高度
 */
private void drawIconThree(Canvas canvas, int degree, Bitmap icon, int width, int height) {
    Camera camera = new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    int centerX = width / 2;
    int centerY = height / 2 - 200;
    int x = centerX - icon.getWidth()/2;
    int y = centerY - icon.getHeight()/2;
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);
    //绘制上半部分
    canvas.save();
    canvas.concat(matrix);
    canvas.clipRect(x, y, x + icon.getWidth(), y + icon.getHeight() / 2);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();

    //绘制下半部分
    canvas.save();
    canvas.concat(matrix);
    if (degree <= 90)
        canvas.clipRect(x, y, x + icon.getWidth(), y + icon.getHeight() / 2);
    else
        canvas.clipRect(x, y + icon.getHeight() / 2, x + icon.getWidth(), y + icon.getHeight());
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180 - degree);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();
}
 
Example 6
Source File: AnimatorProxy.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void transformMatrix(Matrix m, View view) {
    final float w = view.getWidth();
    final float h = view.getHeight();
    final boolean hasPivot = mHasPivot;
    final float pX = hasPivot ? mPivotX : w / 2f;
    final float pY = hasPivot ? mPivotY : h / 2f;

    final float rX = mRotationX;
    final float rY = mRotationY;
    final float rZ = mRotationZ;
    if ((rX != 0) || (rY != 0) || (rZ != 0)) {
        final Camera camera = mCamera;
        camera.save();
        camera.rotateX(rX);
        camera.rotateY(rY);
        camera.rotateZ(-rZ);
        camera.getMatrix(m);
        camera.restore();
        m.preTranslate(-pX, -pY);
        m.postTranslate(pX, pY);
    }

    final float sX = mScaleX;
    final float sY = mScaleY;
    if ((sX != 1.0f) || (sY != 1.0f)) {
        m.postScale(sX, sY);
        final float sPX = -(pX / w) * ((sX * w) - w);
        final float sPY = -(pY / h) * ((sY * h) - h);
        m.postTranslate(sPX, sPY);
    }

    m.postTranslate(mTranslationX, mTranslationY);
}
 
Example 7
Source File: AnimatorProxy.java    From Mover with Apache License 2.0 5 votes vote down vote up
private void transformMatrix(Matrix m, View view) {
    final float w = view.getWidth();
    final float h = view.getHeight();
    final boolean hasPivot = mHasPivot;
    final float pX = hasPivot ? mPivotX : w / 2f;
    final float pY = hasPivot ? mPivotY : h / 2f;

    final float rX = mRotationX;
    final float rY = mRotationY;
    final float rZ = mRotationZ;
    if ((rX != 0) || (rY != 0) || (rZ != 0)) {
        final Camera camera = mCamera;
        camera.save();
        camera.rotateX(rX);
        camera.rotateY(rY);
        camera.rotateZ(-rZ);
        camera.getMatrix(m);
        camera.restore();
        m.preTranslate(-pX, -pY);
        m.postTranslate(pX, pY);
    }

    final float sX = mScaleX;
    final float sY = mScaleY;
    if ((sX != 1.0f) || (sY != 1.0f)) {
        m.postScale(sX, sY);
        final float sPX = -(pX / w) * ((sX * w) - w);
        final float sPY = -(pY / h) * ((sY * h) - h);
        m.postTranslate(sPX, sPY);
    }

    m.postTranslate(mTranslationX, mTranslationY);
}
 
Example 8
Source File: AnimatorProxy.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
private void transformMatrix(Matrix m, View view) {
    final float w = view.getWidth();
    final float h = view.getHeight();
    final boolean hasPivot = mHasPivot;
    final float pX = hasPivot ? mPivotX : w / 2f;
    final float pY = hasPivot ? mPivotY : h / 2f;

    final float rX = mRotationX;
    final float rY = mRotationY;
    final float rZ = mRotationZ;
    if ((rX != 0) || (rY != 0) || (rZ != 0)) {
        final Camera camera = mCamera;
        camera.save();
        camera.rotateX(rX);
        camera.rotateY(rY);
        camera.rotateZ(-rZ);
        camera.getMatrix(m);
        camera.restore();
        m.preTranslate(-pX, -pY);
        m.postTranslate(pX, pY);
    }

    final float sX = mScaleX;
    final float sY = mScaleY;
    if ((sX != 1.0f) || (sY != 1.0f)) {
        m.postScale(sX, sY);
        final float sPX = -(pX / w) * ((sX * w) - w);
        final float sPY = -(pY / h) * ((sY * h) - h);
        m.postTranslate(sPX, sPY);
    }

    m.postTranslate(mTranslationX, mTranslationY);
}
 
Example 9
Source File: AnimatorProxy.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
private void transformMatrix(Matrix m, View view) {
    final float w = view.getWidth();
    final float h = view.getHeight();
    final boolean hasPivot = mHasPivot;
    final float pX = hasPivot ? mPivotX : w / 2f;
    final float pY = hasPivot ? mPivotY : h / 2f;

    final float rX = mRotationX;
    final float rY = mRotationY;
    final float rZ = mRotationZ;
    if ((rX != 0) || (rY != 0) || (rZ != 0)) {
        final Camera camera = mCamera;
        camera.save();
        camera.rotateX(rX);
        camera.rotateY(rY);
        camera.rotateZ(-rZ);
        camera.getMatrix(m);
        camera.restore();
        m.preTranslate(-pX, -pY);
        m.postTranslate(pX, pY);
    }

    final float sX = mScaleX;
    final float sY = mScaleY;
    if ((sX != 1.0f) || (sY != 1.0f)) {
        m.postScale(sX, sY);
        final float sPX = -(pX / w) * ((sX * w) - w);
        final float sPY = -(pY / h) * ((sY * h) - h);
        m.postTranslate(sPX, sPY);
    }

    m.postTranslate(mTranslationX, mTranslationY);
}
 
Example 10
Source File: Rotate3dAnimation.java    From pandroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {


    final float fromDegrees = mFromDegrees;
    float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);

    final float centerX = mCenterX;
    final float centerY = mCenterY;
    final Camera camera = mCamera;


    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }
    switch (rotationAxis) {
        case X:
            camera.rotateX(degrees);
            break;
        case Y:
            camera.rotateY(degrees);
            break;
        case Z:
            camera.rotateZ(degrees);
            break;
    }

    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
 
Example 11
Source File: Rotate3dAnimation.java    From CloudPan with Apache License 2.0 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float fromDegrees = mFromDegrees;
    float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);

    final float centerX = mCenterX;
    final float centerY = mCenterY;
    final Camera camera = mCamera;

    final Matrix matrix = t.getMatrix();

    camera.save();
    if (mReverse) {
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    } else {
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
    }

    if (mRotateType == TYPEX) {
        camera.rotateX(degrees);
    } else if (mRotateType == TYPEY) {
        camera.rotateY(degrees);
    } else if (mRotateType == TYPEZ) {
        camera.rotateZ(degrees);
    }
    camera.getMatrix(matrix);
    camera.restore();

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
 
Example 12
Source File: UEAnimatorProxy.java    From Auie with GNU General Public License v2.0 5 votes vote down vote up
private void transformMatrix(Matrix m, View view) {
    final float w = view.getWidth();
    final float h = view.getHeight();
    final boolean hasPivot = mHasPivot;
    final float pX = hasPivot ? mPivotX : w / 2f;
    final float pY = hasPivot ? mPivotY : h / 2f;

    final float rX = mRotationX;
    final float rY = mRotationY;
    final float rZ = mRotationZ;
    if ((rX != 0) || (rY != 0) || (rZ != 0)) {
        final Camera camera = mCamera;
        camera.save();
        camera.rotateX(rX);
        camera.rotateY(rY);
        camera.rotateZ(-rZ);
        camera.getMatrix(m);
        camera.restore();
        m.preTranslate(-pX, -pY);
        m.postTranslate(pX, pY);
    }

    final float sX = mScaleX;
    final float sY = mScaleY;
    if ((sX != 1.0f) || (sY != 1.0f)) {
        m.postScale(sX, sY);
        final float sPX = -(pX / w) * ((sX * w) - w);
        final float sPY = -(pY / h) * ((sY * h) - h);
        m.postTranslate(sPX, sPY);
    }

    m.postTranslate(mTranslationX, mTranslationY);
}
 
Example 13
Source File: AnimatorProxy.java    From timecat with Apache License 2.0 5 votes vote down vote up
private void transformMatrix(Matrix m, View view) {
    final float w = view.getWidth();
    final float h = view.getHeight();
    final boolean hasPivot = mHasPivot;
    final float pX = hasPivot ? mPivotX : w / 2f;
    final float pY = hasPivot ? mPivotY : h / 2f;

    final float rX = mRotationX;
    final float rY = mRotationY;
    final float rZ = mRotationZ;
    if ((rX != 0) || (rY != 0) || (rZ != 0)) {
        final Camera camera = mCamera;
        camera.save();
        camera.rotateX(rX);
        camera.rotateY(rY);
        camera.rotateZ(-rZ);
        camera.getMatrix(m);
        camera.restore();
        m.preTranslate(-pX, -pY);
        m.postTranslate(pX, pY);
    }

    final float sX = mScaleX;
    final float sY = mScaleY;
    if ((sX != 1.0f) || (sY != 1.0f)) {
        m.postScale(sX, sY);
        final float sPX = -(pX / w) * ((sX * w) - w);
        final float sPY = -(pY / h) * ((sY * h) - h);
        m.postTranslate(sPX, sPY);
    }

    m.postTranslate(mTranslationX, mTranslationY);
}
 
Example 14
Source File: RotationDrawStrategy.java    From styT with Apache License 2.0 5 votes vote down vote up
/**
 * 根据角度绘制图标的类
 * @param canvas 画布
 * @param degree 角度
 * @param icon 图标
 * @param width view宽度
 * @param height view高度
 */
private void drawIconThree(Canvas canvas, int degree, Bitmap icon, int width, int height) {
    Camera camera = new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    int centerX = width / 2;
    int centerY = height / 2 - 200;
    int x = centerX - icon.getWidth()/2;
    int y = centerY - icon.getHeight()/2;
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);
    //绘制上半部分
    canvas.save();
    canvas.concat(matrix);
    canvas.clipRect(x, y, x + icon.getWidth(), y + icon.getHeight() / 2);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();

    //绘制下半部分
    canvas.save();
    canvas.concat(matrix);
    if (degree <= 90)
        canvas.clipRect(x, y, x + icon.getWidth(), y + icon.getHeight() / 2);
    else
        canvas.clipRect(x, y + icon.getHeight() / 2, x + icon.getWidth(), y + icon.getHeight());
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180 - degree);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();
}
 
Example 15
Source File: AnimatorProxy.java    From imsdk-android with MIT License 5 votes vote down vote up
private void transformMatrix(Matrix m, View view) {
    final float w = view.getWidth();
    final float h = view.getHeight();
    final boolean hasPivot = mHasPivot;
    final float pX = hasPivot ? mPivotX : w / 2f;
    final float pY = hasPivot ? mPivotY : h / 2f;

    final float rX = mRotationX;
    final float rY = mRotationY;
    final float rZ = mRotationZ;
    if ((rX != 0) || (rY != 0) || (rZ != 0)) {
        final Camera camera = mCamera;
        camera.save();
        camera.rotateX(rX);
        camera.rotateY(rY);
        camera.rotateZ(-rZ);
        camera.getMatrix(m);
        camera.restore();
        m.preTranslate(-pX, -pY);
        m.postTranslate(pX, pY);
    }

    final float sX = mScaleX;
    final float sY = mScaleY;
    if ((sX != 1.0f) || (sY != 1.0f)) {
        m.postScale(sX, sY);
        final float sPX = -(pX / w) * ((sX * w) - w);
        final float sPY = -(pY / h) * ((sY * h) - h);
        m.postTranslate(sPX, sPY);
    }

    m.postTranslate(mTranslationX, mTranslationY);
}
 
Example 16
Source File: RotationDrawStrategy.java    From FancyView with Apache License 2.0 4 votes vote down vote up
/**
 * 根据角度绘制图标的类
 * @param canvas 画布
 * @param degree 角度
 * @param icon 图标
 * @param width view宽度
 * @param height view高度
 */
private void drawIconTwo(Canvas canvas, int degree, Bitmap icon, int width, int height) {
    Camera camera = new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    int centerX = width / 2;
    int centerY = height / 2 - 200;
    int x = centerX - icon.getWidth()/2;
    int y = centerY - icon.getHeight()/2;
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);

    //绘制左半部分
    canvas.save();
    canvas.concat(matrix);
    canvas.clipRect(x, y, x + icon.getWidth() / 2, y + icon.getHeight() / 2);
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();

    //绘制右半部分
    canvas.save();
    canvas.concat(matrix);
    if (degree <= 90)
        canvas.clipRect(x , y , x + icon.getWidth() / 2, y + icon.getHeight() / 2);
    else
        canvas.clipRect(x + icon.getWidth() / 2, y, x + icon.getWidth(), y + icon.getHeight() / 2);
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180);
    camera.rotateY(180 - degree);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();
}
 
Example 17
Source File: RotationDrawStrategy.java    From styT with Apache License 2.0 4 votes vote down vote up
/**
 * 根据角度绘制图标的类
 * @param canvas 画布
 * @param degree 角度
 * @param icon 图标
 * @param width view宽度
 * @param height view高度
 */
private void drawIconTwo(Canvas canvas, int degree, Bitmap icon, int width, int height) {
    Camera camera = new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    int centerX = width / 2;
    int centerY = height / 2 - 200;
    int x = centerX - icon.getWidth()/2;
    int y = centerY - icon.getHeight()/2;
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);

    //绘制左半部分
    canvas.save();
    canvas.concat(matrix);
    canvas.clipRect(x, y, x + icon.getWidth() / 2, y + icon.getHeight() / 2);
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();

    //绘制右半部分
    canvas.save();
    canvas.concat(matrix);
    if (degree <= 90)
        canvas.clipRect(x , y , x + icon.getWidth() / 2, y + icon.getHeight() / 2);
    else
        canvas.clipRect(x + icon.getWidth() / 2, y, x + icon.getWidth(), y + icon.getHeight() / 2);
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180);
    camera.rotateY(180 - degree);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();
}
 
Example 18
Source File: ViewPropertyAnimation.java    From FragmentAnimations with Apache License 2.0 4 votes vote down vote up
protected void applyTransformation(Transformation t) {
    final Matrix m = t.getMatrix();
    final float w = mWidth;
    final float h = mHeight;
    final float pX = mPivotX;
    final float pY = mPivotY;

    final float rX = mRotationX;
    final float rY = mRotationY;
    final float rZ = mRotationZ;
    if ((rX != 0) || (rY != 0) || (rZ != 0)) {
        final Camera camera = mCamera;
        camera.save();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
            camera.setLocation(mCameraX, mCameraY, mCameraZ);
        }
        if (mTranslationZ != 0) {
            camera.translate(0, 0, mTranslationZ);
        }
        camera.rotateX(rX);
        camera.rotateY(rY);
        camera.rotateZ(-rZ);
        camera.getMatrix(m);
        camera.restore();
        m.preTranslate(-pX, -pY);
        m.postTranslate(pX, pY);
    }

    final float sX = mScaleX;
    final float sY = mScaleY;
    if ((sX != 1.0f) || (sY != 1.0f)) {
        m.postScale(sX, sY);
        final float sPX = -(pX / w) * ((sX * w) - w);
        final float sPY = -(pY / h) * ((sY * h) - h);
        m.postTranslate(sPX, sPY);
    }

    m.postTranslate(mTranslationX, mTranslationY);

    t.setAlpha(mAlpha);
}
 
Example 19
Source File: AnimatorProxy.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
private void a(Matrix matrix, View view)
{
    float f1 = view.getWidth();
    float f2 = view.getHeight();
    boolean flag = d;
    float f3;
    float f4;
    float f5;
    float f6;
    float f7;
    float f8;
    float f9;
    if (flag)
    {
        f3 = f;
    } else
    {
        f3 = f1 / 2.0F;
    }
    if (flag)
    {
        f4 = g;
    } else
    {
        f4 = f2 / 2.0F;
    }
    f5 = h;
    f6 = i;
    f7 = j;
    if (f5 != 0.0F || f6 != 0.0F || f7 != 0.0F)
    {
        Camera camera = c;
        camera.save();
        camera.rotateX(f5);
        camera.rotateY(f6);
        camera.rotateZ(-f7);
        camera.getMatrix(matrix);
        camera.restore();
        matrix.preTranslate(-f3, -f4);
        matrix.postTranslate(f3, f4);
    }
    f8 = k;
    f9 = l;
    if (f8 != 1.0F || f9 != 1.0F)
    {
        matrix.postScale(f8, f9);
        matrix.postTranslate(-(f3 / f1) * (f8 * f1 - f1), -(f4 / f2) * (f9 * f2 - f2));
    }
    matrix.postTranslate(m, n);
}
 
Example 20
Source File: RotationDrawStrategy.java    From youqu_master with Apache License 2.0 4 votes vote down vote up
/**
 * 根据角度绘制图标的类
 * @param canvas 画布
 * @param degree 角度
 * @param icon 图标
 * @param width view宽度
 * @param height view高度
 */
private void drawIconTwo(Canvas canvas, int degree, Bitmap icon, int width, int height) {
    Camera camera = new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    int centerX = width / 2;
    int centerY = height / 2 - 200;
    int x = centerX - icon.getWidth()/2;
    int y = centerY - icon.getHeight()/2;
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);

    //绘制左半部分
    canvas.save();
    canvas.concat(matrix);
    canvas.clipRect(x, y, x + icon.getWidth() / 2, y + icon.getHeight() / 2);
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();

    //绘制右半部分
    canvas.save();
    canvas.concat(matrix);
    if (degree <= 90)
        canvas.clipRect(x , y , x + icon.getWidth() / 2, y + icon.getHeight() / 2);
    else
        canvas.clipRect(x + icon.getWidth() / 2, y, x + icon.getWidth(), y + icon.getHeight() / 2);
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180);
    camera.rotateY(180 - degree);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();
}