本文整理匯總了Java中android.graphics.Camera.translate方法的典型用法代碼示例。如果您正苦於以下問題:Java Camera.translate方法的具體用法?Java Camera.translate怎麽用?Java Camera.translate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.Camera
的用法示例。
在下文中一共展示了Camera.translate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: applyTransformation
import android.graphics.Camera; //導入方法依賴的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);
}
示例2: applyTransformation
import android.graphics.Camera; //導入方法依賴的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);
}
示例3: applyTransformation
import android.graphics.Camera; //導入方法依賴的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);
}
示例4: applyTransformation
import android.graphics.Camera; //導入方法依賴的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 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);
}
示例5: applyTransformation
import android.graphics.Camera; //導入方法依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float tmpFromDegrees = fromDegrees;
float degrees = tmpFromDegrees + ((toDegrees - tmpFromDegrees) * interpolatedTime);
float tmpCenterX = centerX;
float tmpCenterY = centerY;
Camera tmpCamera = camera;
Matrix matrix = t.getMatrix();
LogUtils.d("interpolatedTime: " + interpolatedTime);
tmpCamera.save();
if (reverse) {
tmpCamera.translate(0f, 0f, depthZ * interpolatedTime);
} else {
tmpCamera.translate(0f, 0f, depthZ * (1.0f - interpolatedTime));
}
tmpCamera.rotateY(degrees);
tmpCamera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-tmpCenterX, -tmpCenterY);
matrix.postTranslate(tmpCenterX, tmpCenterY);
super.applyTransformation(interpolatedTime, t);
}
示例6: applyTransformation
import android.graphics.Camera; //導入方法依賴的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.setLocation(0, 0, 60);
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例7: applyTransformation
import android.graphics.Camera; //導入方法依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = mFromDegrees;
float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
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.rotateX(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-mCenterX * mWidth, -mCenterY * mHeight);
matrix.postTranslate(mCenterX * mWidth, mCenterY * mHeight);
}
示例8: applyTransformation
import android.graphics.Camera; //導入方法依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = this.fromDegrees;
float degrees = fromDegrees + ((toDegrees - fromDegrees) * interpolatedTime);
final float centerX = xCenter;
final float centerY = yCenter;
final Camera camera = this.camera;
final Matrix matrix = t.getMatrix(); //保存一次camera初始狀態,用於restore()
camera.save();
if (reverse) {
camera.translate(0.0f, 0.0f, zDepth * interpolatedTime);
} else {
camera.translate(0.0f, 0.0f, zDepth * (1.0f - interpolatedTime));
}
//圍繞Y軸旋轉degrees度
camera.rotateY(degrees);
//行camera中取出矩陣,賦值給matrix
camera.getMatrix(matrix);
//camera恢複到初始狀態,繼續用於下次的計算
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例9: applyTransformation
import android.graphics.Camera; //導入方法依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float fromDegrees = m_fromDegree;
float degrees = fromDegrees + ((m_toDegree - fromDegrees) * interpolatedTime);
final float centerX = m_centerX;
final float centerY = m_centerY;
final Camera camera = m_camera;
final Matrix matrix = t.getMatrix();
camera.save();
if (m_reverse) {
camera.translate(0.0f, 0.0f, m_depthZ * interpolatedTime);
} else {
camera.translate(0.0f, 0.0f, m_depthZ * (1.0f - interpolatedTime));
}
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例10: applyTransformation
import android.graphics.Camera; //導入方法依賴的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));
// 繞y軸旋轉
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
// 修正失真,主要修改 MPERSP_0 和 MPERSP_1
float[] mValues = new float[9];
matrix.getValues(mValues); //獲取數值
mValues[6] = mValues[6] / scale; //數值修正
mValues[7] = mValues[7] / scale; //數值修正
matrix.setValues(mValues); //重新賦值
// 調節中心點
matrix.preTranslate(-centerX, -centerY);
matrix.postScale(centerX, centerY);
}
示例11: applyTransformation
import android.graphics.Camera; //導入方法依賴的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);
}
示例12: applyTransformation
import android.graphics.Camera; //導入方法依賴的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 (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);
}
示例13: applyTransformation
import android.graphics.Camera; //導入方法依賴的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));
}
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);
}
示例14: applyTransformation
import android.graphics.Camera; //導入方法依賴的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();
// camera.translate,這個方法接受3個參數,分別是x,y,z三個軸的偏移量,我們這裏隻將z軸進行了偏移,
if (mReverse) {
// z的偏移會越來越大。這就會形成這樣一個效果,view從近到遠
camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
} else {
// z的偏移會越來越小。這就會形成這樣一個效果,我們的View從一個很遠的地方向我們移過來,越來越近,最終移到了我們的窗口上麵~
camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
}
// 是給我們的View加上旋轉效果,在移動的過程中,視圖還會移Y軸為中心進行旋轉。
camera.rotateY(degrees);
// 是給我們的View加上旋轉效果,在移動的過程中,視圖還會移X軸為中心進行旋轉。
// camera.rotateX(degrees);
// 這個是將我們剛才定義的一係列變換應用到變換矩陣上麵,調用完這句之後,我們就可以將camera的位置恢複了,以便下一次再使用。
camera.getMatrix(matrix);
// camera位置恢複
camera.restore();
// 以View的中心點為旋轉中心,如果不加這兩句,就是以(0,0)點為旋轉中心
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}
示例15: onDraw
import android.graphics.Camera; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);
Matrix matrix=new Matrix();
matrix.postTranslate(100, 200);
matrix.mapPoints(dst, src);
System.out.println("mapPoints_____>>>src first Point X:" + src[0] + "\t Y:" + src[1]);//src是記錄的原點 [0,0]點
System.out.println("mapPoints_____>>>dst first Point X:"+ dst[0]+"\t Y:"+dst[1]);//dst是 src通過矩陣變換的點 [0,0]點對應到 [100,200]
canvas.drawBitmap(bt, matrix, paint);
//通過下邊的三個方法 可以通過 dst矩陣變化後的點 通過矩陣 逆向方法 轉換到 invertDst 即是src原點位置 所以dst中[100,200]的點 即是inverDst[0,0]這個點即 src[0,0]點
Matrix invertMatrix = new Matrix();
matrix.invert(invertMatrix);
invertMatrix.mapPoints(invertDst, dst);
System.out.println("invertMatrix_____>>>mapPoints invertDst first Point X:" + invertDst[0] + "\t Y:" + invertDst[1]);
//測試postConcat
Matrix matrixCon =new Matrix();
matrixCon.postTranslate(100, 200);
matrix.postConcat(matrixCon);
matrix.mapPoints(dst, src);
System.out.println("matrixCon: mapPoints_____>>>src first Point X:" + src[0] + "\t Y:" + src[1]);//src是記錄的原點 [0,0]點
System.out.println("matrixCon: mapPoints_____>>>dst first Point X:"+ dst[0]+"\t Y:"+dst[1]);
//測試Camera getMatrix
Camera camera=new Camera();
camera.save();
camera.translate(100,200,0);
camera.getMatrix(matrix);
camera.restore();
matrix.mapPoints(dst, src);
System.out.println("Camera: mapPoints_____>>>src first Point X:" + src[0] + "\t Y:" + src[1]);//src是記錄的原點 [0,0]點
System.out.println("Camera: mapPoints_____>>>dst first Point X:"+ dst[0]+"\t Y:"+dst[1]);
}