本文整理汇总了Java中android.graphics.Matrix.preTranslate方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.preTranslate方法的具体用法?Java Matrix.preTranslate怎么用?Java Matrix.preTranslate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Matrix
的用法示例。
在下文中一共展示了Matrix.preTranslate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyTransformation
import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final double radians = Math.PI * interpolatedTime;
float degrees = (float) (180.0 * radians / Math.PI);
if (interpolatedTime >= 0.5f) { // Alternate the visibility of views at the exact half of animation duration.
degrees -= 180.f;
fromView.setVisibility(View.GONE);
toView.setVisibility(View.VISIBLE);
}
if (forward)
degrees = -degrees;
final Matrix matrix = t.getMatrix();
camera.save();
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例2: getSymmetricalMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
/**
* 关于两个control连线的对称矩阵
* @return
*/
private Matrix getSymmetricalMatrix() {
// 根据网上资料,有一点错误,就是先-b,再b
float k = (mBzControl1.y - mBzControl2.y) / (mBzControl1.x - mBzControl2.x);
float[] values = new float[9];
values[0] = -1 * (k * k - 1) / (k * k + 1);
values[1] = 2 * k / (k * k + 1);
values[3] = values[1];
values[4] = -values[0];
values[8] = 1;
float b = mBzControl1.y - mBzControl1.x * k;
Matrix matrix = new Matrix();
matrix.setValues(values);
matrix.preTranslate(0, -b);
matrix.postTranslate(0, b);
return matrix;
}
示例3: transformImageBitmap
import android.graphics.Matrix; //导入方法依赖的package包/类
private void transformImageBitmap(View child, Transformation t,
int rotationAngle) {
mCamera.save();
final Matrix imageMatrix = t.getMatrix();
final int imageHeight = child.getLayoutParams().height;
final int imageWidth = child.getLayoutParams().width;
final int rotation = Math.abs(rotationAngle);
mCamera.translate(0.0f, 0.0f, 100.0f);
// As the angle of the view gets less, zoom in
if (rotation < mMaxRotationAngle) {
float zoomAmount = (float) (mMaxZoom + (rotation * 1.5));
mCamera.translate(0.0f, 0.0f, zoomAmount);
}
mCamera.rotateY(rotationAngle);
mCamera.getMatrix(imageMatrix);
imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2));
imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2));
mCamera.restore();
}
示例4: applyTransformation
import android.graphics.Matrix; //导入方法依赖的package包/类
@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);
}
示例5: cropAndRescaleBitmap
import android.graphics.Matrix; //导入方法依赖的package包/类
public static void cropAndRescaleBitmap(final Bitmap src, final Bitmap dst, int sensorOrientation) {
Assert.assertEquals(dst.getWidth(), dst.getHeight());
final float minDim = Math.min(src.getWidth(), src.getHeight());
final Matrix matrix = new Matrix();
// We only want the center square out of the original rectangle.
final float translateX = -Math.max(0, (src.getWidth() - minDim) / 2);
final float translateY = -Math.max(0, (src.getHeight() - minDim) / 2);
matrix.preTranslate(translateX, translateY);
final float scaleFactor = dst.getHeight() / minDim;
matrix.postScale(scaleFactor, scaleFactor);
// Rotate around the center if necessary.
if (sensorOrientation != 0) {
matrix.postTranslate(-dst.getWidth() / 2.0f, -dst.getHeight() / 2.0f);
matrix.postRotate(sensorOrientation);
matrix.postTranslate(dst.getWidth() / 2.0f, dst.getHeight() / 2.0f);
}
final Canvas canvas = new Canvas(dst);
canvas.drawBitmap(src, matrix, null);
}
示例6: applyTransformation
import android.graphics.Matrix; //导入方法依赖的package包/类
@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);
}
示例7: applyTransformation
import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float deg = 0.0F + 360.0F * interpolatedTime;
Matrix matrix = t.getMatrix();
mCamera.save();
if (mMode == Mode.X)
mCamera.rotateX(deg);
if (mMode == Mode.Y)
mCamera.rotateY(deg);
if (mMode == Mode.Z)
mCamera.rotateZ(deg);
mCamera.getMatrix(matrix);
mCamera.restore();
matrix.preTranslate(-mCenterX, -mCenterY);
matrix.postTranslate(mCenterX, mCenterY);
}
示例8: applyTransformation
import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float degrees = fromDegrees + ((toDegrees - fromDegrees) * interpolatedTime);
final Matrix matrix = t.getMatrix();
final Camera camera = mCamera;
camera.save();
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例9: transformMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
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);
}
示例10: offsetDescendantMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) {
ViewParent parent = view.getParent();
if ((parent instanceof View) && parent != target) {
View vp = (View) parent;
offsetDescendantMatrix(target, vp, m);
m.preTranslate((float) (-vp.getScrollX()), (float) (-vp.getScrollY()));
}
m.preTranslate((float) view.getLeft(), (float) view.getTop());
if (!view.getMatrix().isIdentity()) {
m.preConcat(view.getMatrix());
}
}
示例11: offsetDescendantMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) {
final ViewParent parent = view.getParent();
if (parent instanceof View && parent != target) {
final View vp = (View) parent;
offsetDescendantMatrix(target, vp, m);
m.preTranslate(-vp.getScrollX(), -vp.getScrollY());
}
m.preTranslate(view.getLeft(), view.getTop());
if (!view.getMatrix().isIdentity()) {
m.preConcat(view.getMatrix());
}
}
示例12: getRotateMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
public Matrix getRotateMatrix() {
// By default this is an identity matrix
Matrix matrix = new Matrix();
if (bitmap != null && rotation != 0) {
// We want to do the rotation at origin, but since the bounding
// rectangle will be changed after rotation, so the delta values
// are based on old & new width/height respectively.
int cx = bitmap.getWidth() / 2;
int cy = bitmap.getHeight() / 2;
matrix.preTranslate(-cx, -cy);
matrix.postRotate(rotation);
matrix.postTranslate(getWidth() / 2, getHeight() / 2);
}
return matrix;
}
示例13: drawResizedBitmap
import android.graphics.Matrix; //导入方法依赖的package包/类
private void drawResizedBitmap(final Bitmap src, final Bitmap dst) {
Display getOrient = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int orientation = Configuration.ORIENTATION_UNDEFINED;
Point point = new Point();
getOrient.getSize(point);
int screen_width = point.x;
int screen_height = point.y;
Log.d(TAG, String.format("screen size (%d,%d)", screen_width, screen_height));
if (screen_width < screen_height) {
orientation = Configuration.ORIENTATION_PORTRAIT;
mScreenRotation = -90;
} else {
orientation = Configuration.ORIENTATION_LANDSCAPE;
mScreenRotation = 0;
}
Assert.assertEquals(dst.getWidth(), dst.getHeight());
final float minDim = Math.min(src.getWidth(), src.getHeight());
final Matrix matrix = new Matrix();
// We only want the center square out of the original rectangle.
final float translateX = -Math.max(0, (src.getWidth() - minDim) / 2);
final float translateY = -Math.max(0, (src.getHeight() - minDim) / 2);
matrix.preTranslate(translateX, translateY);
final float scaleFactor = dst.getHeight() / minDim;
matrix.postScale(scaleFactor, scaleFactor);
// Rotate around the center if necessary.
if (mScreenRotation != 0) {
matrix.postTranslate(-dst.getWidth() / 2.0f, -dst.getHeight() / 2.0f);
matrix.postRotate(mScreenRotation);
matrix.postTranslate(dst.getWidth() / 2.0f, dst.getHeight() / 2.0f);
}
final Canvas canvas = new Canvas(dst);
canvas.drawBitmap(src, matrix, null);
}
示例14: offsetDescendantMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
private static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) {
final ViewParent parent = view.getParent();
if (parent instanceof View && parent != target) {
final View vp = (View) parent;
offsetDescendantMatrix(target, vp, m);
m.preTranslate(-vp.getScrollX(), -vp.getScrollY());
}
m.preTranslate(view.getLeft(), view.getTop());
if (!view.getMatrix().isIdentity()) {
m.preConcat(view.getMatrix());
}
}
示例15: applyTransformation
import android.graphics.Matrix; //导入方法依赖的package包/类
@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 (mRotateX)
camera.rotateX(degrees);
else
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}