本文整理了Java中android.graphics.Camera.translate()
方法的一些代码示例,展示了Camera.translate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Camera.translate()
方法的具体详情如下:
包路径:android.graphics.Camera
类名称:Camera
方法名:translate
暂无
代码示例来源:origin: JingYeoh/FragmentRigger
@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);
}
}
代码示例来源:origin: AigeStudio/WheelPicker
mCamera.translate(0, 0, computeDepth((int) degree));
mCamera.getMatrix(mMatrixDepth);
mCamera.restore();
代码示例来源:origin: kakajika/FragmentAnimations
camera.translate(0, 0, mTranslationZ);
代码示例来源:origin: luhaoaimama1/zone-sdk
public CameraInvert translate_3D(float x, float y, float z) {
this.tz = -z;
mCamera.translate(x, -y, -z);
return this;
}
代码示例来源:origin: luhaoaimama1/zone-sdk
private CameraInvert translate_(float x, float y, float z) {
mCamera.translate(x, -y, -z);
return this;
}
代码示例来源:origin: xenione/tab-digit
public static void translateY(Matrix matrix, float dy) {
synchronized (camera) {
camera.save();
camera.translate(0, dy, 0);
camera.getMatrix(matrix);
camera.restore();
}
}
}
代码示例来源:origin: xenione/tab-digit
public static void translate(Matrix matrix, float dx, float dy, float dz) {
synchronized (camera) {
camera.save();
camera.translate(dx, dy, dz);
camera.getMatrix(matrix);
camera.restore();
}
}
代码示例来源:origin: vogellacompany/codeexamples-android
private void prepareMatrix(final Matrix outMatrix, int distanceY, int r) {
// clip the distance
final int d = Math.min(r, Math.abs(distanceY));
// use circle formula
final float translateZ = (float) Math.sqrt((r * r) - (d * d));
// solve for t: d = r*cos(t)
double radians = Math.acos((float) d / r);
double degree = 90 - (180 / Math.PI) * radians;
mCamera.save();
mCamera.translate(0, 0, r - translateZ);
mCamera.rotateX((float) degree);
if (distanceY < 0) {
degree = 360 - degree;
}
mCamera.rotateY((float) degree);
mCamera.getMatrix(outMatrix);
mCamera.restore();
// highlight elements in the middle
mPaint.setColorFilter(calculateLight((float) degree));
}
代码示例来源:origin: luhaoaimama1/zone-sdk
camera.translate(100,200,0);
camera.getMatrix(matrix);
camera.restore();
代码示例来源:origin: YiChaoLove/CoverFlow
private void prepareMatrix(final Matrix outMatrix, int distance, int r) {
//clip the distance
final int d = Math.min(r, Math.abs(distance));
//use circle formula
final float translateZ = (float) Math.sqrt((r * r) - (d * d));
mCamera.save();
float offset = r - translateZ;
mCamera.translate(0, 0, offset);
if (isTilted) {
float deg = offset / TILTED_FACTOR;
if (distance > 0) {
mCamera.rotateY(deg);
} else {
mCamera.rotateY(- deg);
}
}
mCamera.getMatrix(outMatrix);
mCamera.restore();
}
代码示例来源:origin: kingwang666/BookLoadingView
@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);
}
}
代码示例来源:origin: qiubiteme/android_api_demos
@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);
}
}
代码示例来源:origin: THEONE10211024/ApiDemos
@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);
}
}
代码示例来源:origin: leeowenowen/beauty-of-math
@Override
public void draw(Canvas canvas) {
if (mDirection == DIRECTION_LEFT) {
Camera camera = new Camera();
camera.translate(mWidth, 0, 0);
camera.rotate(0, 180, 0);
camera.applyToCanvas(canvas);
}
doDraw(canvas);
}
代码示例来源:origin: zyyoona7/WheelPicker
float offsetZ, int centerToBaselineY) {
mCamera.save();
mCamera.translate(0, 0, offsetZ);
mCamera.rotateX(rotateX);
mCamera.getMatrix(mMatrix);
代码示例来源:origin: InnoFang/Android-Code-Demos
camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
else
camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));
代码示例来源:origin: luhaoaimama1/zone-sdk
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void applyTransformation(
float interpolatedTime,
Transformation t) {
final Matrix matrix = t.getMatrix();
mCamera.save();
mCamera.translate(mX * interpolatedTime, mY * interpolatedTime, mZ * interpolatedTime);
mCamera.rotateX(mRotateX * interpolatedTime);
mCamera.rotate(0, mRotateY * interpolatedTime, 0);
mCamera.rotateZ(mRotateZ * interpolatedTime);
// 将旋转变换作用到matrix上
mCamera.getMatrix(matrix);
mCamera.restore();
System.out.println("mRotateX:___" + mRotateX + "\t mRotateY:" + mRotateY + "\t mRotateZ:" + mRotateZ);
System.out.println("camera x:" + mCamera.getLocationX() + "\t y:" + mCamera.getLocationY() + "\t z:" + mCamera.getLocationZ());
System.out.println("Matrix:___" + matrix.toString());
// 通过pre方法设置矩阵作用前的偏移量来改变旋转中心
// matrix.preTranslate(mCenterWidth, mCenterHeight);
// matrix.postTranslate(-mCenterWidth, -mCenterHeight);
}
}
代码示例来源:origin: geminiwen/AndroidCubeDemo
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
super.applyTransformation(interpolatedTime, t);
float rotate = (sFinalDegree - sFinalDegree * interpolatedTime);
mCamera.save();
mCamera.translate((-mWidth * interpolatedTime), 0, 0);
mCamera.rotateY(rotate);
mCamera.getMatrix(mMatrix);
mCamera.restore();
mMatrix.postTranslate(mWidth, mHeight / 2);
mMatrix.preTranslate(0, -mHeight / 2);
t.getMatrix().postConcat(mMatrix);
}
}
代码示例来源:origin: geminiwen/AndroidCubeDemo
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
super.applyTransformation(interpolatedTime, t);
float rotate = (- sFinalDegree * interpolatedTime);
mCamera.save();
mCamera.translate((mWidth - interpolatedTime * mWidth), 0, 0);
mCamera.rotateY(rotate);
mCamera.getMatrix(mMatrix);
mCamera.restore();
mMatrix.postTranslate(0, mHeight / 2);
mMatrix.preTranslate(- mWidth, - mHeight / 2);
t.getMatrix().postConcat(mMatrix);
}
}
代码示例来源:origin: BoBoMEe/Android-Demos
@Override
protected void onDraw(Canvas canvas) {
if (mBitmap == null) {
// 如果Bitmap对象还不存在,先使用父类的onDraw方法进行绘制
super.onDraw(canvas);
} else {
if (isImageVisible()) {
// 绘图时需要注意,只有当图片可见的时候才进行绘制,这样可以节省运算效率
computeRotateData();
mCamera.save();
mCamera.translate(0.0f, 0.0f, mDeep);
mCamera.rotateY(mRotateDegree);
mCamera.getMatrix(mMaxtrix);
mCamera.restore();
mMaxtrix.preTranslate(-mDx, -getHeight() / 2);
mMaxtrix.postTranslate(mDx, getHeight() / 2);
canvas.drawBitmap(mBitmap, mMaxtrix, null);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!