@Override protected void applyTransformation(float interpolatedTime, Transformation t) { View view = mView.get(); if (view != null) { t.setAlpha(mAlpha); transformMatrix(t.getMatrix(), view); } } }
public TransformationAssert hasMatrix(Matrix matrix) { isNotNull(); Matrix actualMatrix = actual.getMatrix(); assertThat(actualMatrix) // .overridingErrorMessage("Expected matrix <%s> but was <%s>.", matrix, actualMatrix) // .isEqualTo(matrix); return this; }
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { Camera camera = new Camera(); camera.save(); // 设置camera动作为绕Y轴旋转 // 总共旋转180度,因此计算在每个补间时间点interpolatedTime的角度即为两着相乘 // camera.rotateX(deg * interpolatedTime); camera.rotateY(180 * interpolatedTime); // camera.rotateZ(180 * interpolatedTime); // // 根据camera动作产生一个matrix,赋给Transformation的matrix,以用来设置动画效果 Matrix matrix = t.getMatrix(); camera.getMatrix(matrix); camera.restore(); //经过以下平移,才能以view的中心点进行翻转 matrix.preTranslate(-view.getWidth() / 2, -view.getHeight() / 2); matrix.postTranslate(view.getWidth() / 2, view.getHeight() / 2); } }
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final Camera camera = mCamera; final Matrix matrix = t.getMatrix(); final float fromDegrees = mFromDegrees; final float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); camera.save(); camera.rotateX(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-mCenterX, -mCenterY); matrix.postTranslate(mCenterX, mCenterY); }
@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); }
final Matrix matrix = t.getMatrix(); camera.save(); camera.rotateY(degrees);
@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)); } camera.rotateY(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); } }
Transformation transformation = new Transformation(); float[] matrix = new float[9]; currentAnimation.getTransformation(AnimationUtils.currentAnimationTimeMillis(), transformation); transformation.getMatrix().getValues(matrix); float y = matrix[Matrix.MTRANS_Y];
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { View view = mView.get(); if (view != null) { t.setAlpha(mAlpha); transformMatrix(t.getMatrix(), view); } } }
transformation.getMatrix().getValues(matrix); float y = matrix[Matrix.MTRANS_Y];
protected void applyTransformation(Transformation t) { final Matrix m = t.getMatrix(); final float w = mWidth; final float h = mHeight;
public class myAnimation extends Animation { public myAnimation() { } @Override boolean willChangeTransformationMatrix() { return true; } @Override void applyTransformation(float interpolatedTime, Transformation t) { Matrix m = t.getMatrix(); // do whatever you want to the matrix here, using the interpolatedTime } }
private class MyAnimation extends Animation { private Matrix matrix; public MyAnimation(Matrix matrix) { this.matrix = matrix; } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); t.getMatrix().set(matrix); } }
protected void applyTransformation(float interpolatedTime, Transformation t) { Matrix tran = t.getMatrix(); tran.postTranslate(_offsetx, _offsety); tran.postRotate(_angel, _anchorx, _anchory); } };
protected boolean getChildStaticTransformation(View child, Transformation t) { t.clear(); t.setTransformationType(Transformation.TYPE_MATRIX); final Matrix matrix = t.getMatrix(); float childCenterPos = child.getLeft() + (child.getWidth() / 2f); float center = getWidth() / 2; float diff = Math.abs(center - childCenterPos); float scale = diff / getWidth(); matrix.setScale(1 - (scale), 1 - (scale)); return true; }
Transformation outTransformation = new Transformation(); myAnimation.getTransformation(currentTime, outTransformation); Matrix transformationMatrix = outTransformation.getMatrix(); float[] matrixValues = new float[9]; transformationMatrix.getValues(matrixValues); float transX = matrixValues[Matrix.MTRANS_X]; float transY = matrixValues[Matrix.MTRANS_Y];
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float dx = calculateBezier(interpolatedTime, mStart.x, mControl.x, mEnd.x); final float dy = calculateBezier(interpolatedTime, mStart.y, mControl.y, mEnd.y); t.getMatrix().setTranslate(dx, dy); }
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { if (mTransformView == child && applyTransformation()) { canvas.save(); canvas.concat(mTransformation.getMatrix()); canvas.setDrawFilter(mPaintFlagsDrawFilter); boolean drawChild = super.drawChild(canvas, child, drawingTime); canvas.restore(); return drawChild; } return super.drawChild(canvas, child, drawingTime); }
private final Matrix getChildTransformationMatrix(final CarouselItemHolder item, final Transformation transformation) { float scale = item.getItemScale(); float scaleXOff = item.getWidth() / 2.0f * (1.0f - scale); float centerX = (float) getWidth() / 2; scaleXOff += (item.getItemX() + item.getWidth() / 2 - centerX) * mViewCoefficientHolder.mDiameterScale; final Matrix matrix = transformation.getMatrix(); matrix.setTranslate(item.getItemX() + scaleXOff, item.getItemY()); matrix.preScale(scale, scale); return matrix; }