Search in sources :

Example 21 with Camera

use of android.graphics.Camera in project Side-Menu.Android by Yalantis.

the class FlipAnimation method initialize.

@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
    super.initialize(width, height, parentWidth, parentHeight);
    mCamera = new Camera();
}
Also used : Camera(android.graphics.Camera)

Example 22 with Camera

use of android.graphics.Camera in project Side-Menu.Android by Yalantis.

the class FlipAnimation method applyTransformation.

@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();
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
Also used : Matrix(android.graphics.Matrix) Camera(android.graphics.Camera)

Example 23 with Camera

use of android.graphics.Camera in project StereoView by ImmortalZ.

the class StereoView method init.

/**
     * 初始化数据
     */
private void init(Context context) {
    mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    mCamera = new Camera();
    mMatrix = new Matrix();
    if (mScroller == null) {
        mScroller = new Scroller(context);
    }
}
Also used : Matrix(android.graphics.Matrix) Camera(android.graphics.Camera) Scroller(android.widget.Scroller)

Example 24 with Camera

use of android.graphics.Camera in project NineOldAndroids by JakeWharton.

the class AnimatorProxy method transformMatrix.

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);
}
Also used : Camera(android.graphics.Camera)

Example 25 with Camera

use of android.graphics.Camera in project XobotOS by xamarin.

the class View method updateMatrix.

/**
     * Recomputes the transform matrix if necessary.
     */
private void updateMatrix() {
    final TransformationInfo info = mTransformationInfo;
    if (info == null) {
        return;
    }
    if (info.mMatrixDirty) {
        // Figure out if we need to update the pivot point
        if ((mPrivateFlags & PIVOT_EXPLICITLY_SET) == 0) {
            if ((mRight - mLeft) != info.mPrevWidth || (mBottom - mTop) != info.mPrevHeight) {
                info.mPrevWidth = mRight - mLeft;
                info.mPrevHeight = mBottom - mTop;
                info.mPivotX = info.mPrevWidth / 2f;
                info.mPivotY = info.mPrevHeight / 2f;
            }
        }
        info.mMatrix.reset();
        if (!nonzero(info.mRotationX) && !nonzero(info.mRotationY)) {
            info.mMatrix.setTranslate(info.mTranslationX, info.mTranslationY);
            info.mMatrix.preRotate(info.mRotation, info.mPivotX, info.mPivotY);
            info.mMatrix.preScale(info.mScaleX, info.mScaleY, info.mPivotX, info.mPivotY);
        } else {
            if (info.mCamera == null) {
                info.mCamera = new Camera();
                info.matrix3D = new Matrix();
            }
            info.mCamera.save();
            info.mMatrix.preScale(info.mScaleX, info.mScaleY, info.mPivotX, info.mPivotY);
            info.mCamera.rotate(info.mRotationX, info.mRotationY, -info.mRotation);
            info.mCamera.getMatrix(info.matrix3D);
            info.matrix3D.preTranslate(-info.mPivotX, -info.mPivotY);
            info.matrix3D.postTranslate(info.mPivotX + info.mTranslationX, info.mPivotY + info.mTranslationY);
            info.mMatrix.postConcat(info.matrix3D);
            info.mCamera.restore();
        }
        info.mMatrixDirty = false;
        info.mMatrixIsIdentity = info.mMatrix.isIdentity();
        info.mInverseMatrixDirty = true;
    }
}
Also used : Matrix(android.graphics.Matrix) Camera(android.graphics.Camera)

Aggregations

Camera (android.graphics.Camera)30 Matrix (android.graphics.Matrix)11 Paint (android.graphics.Paint)3 SuppressLint (android.annotation.SuppressLint)1 Point (android.graphics.Point)1 Transformation (android.view.animation.Transformation)1 Scroller (android.widget.Scroller)1