本文整理了Java中android.graphics.Camera.rotateY()
方法的一些代码示例,展示了Camera.rotateY()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Camera.rotateY()
方法的具体详情如下:
包路径:android.graphics.Camera
类名称:Camera
方法名:rotateY
暂无
代码示例来源:origin: commonsguy/cw-omnibus
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);
}
代码示例来源:origin: JingYeoh/FragmentRigger
@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);
}
}
代码示例来源:origin: stackoverflow.com
Camera mCamera;
mCamera.save();
mCamera.rotateY(distance/40f); //you should divide by the parent's width so your rotation values are 0>=rotation >= MAX_ROTATION
mCamera.getMatrix(matrix);
mCamera.restore();
代码示例来源:origin: Bilibili/DanmakuFlameMaster
private int saveCanvas(BaseDanmaku danmaku, Canvas canvas, float left, float top) {
camera.save();
if (locationZ !=0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
camera.setLocation(0, 0, locationZ);
}
camera.rotateY(-danmaku.rotationY);
camera.rotateZ(-danmaku.rotationZ);
camera.getMatrix(matrix);
matrix.preTranslate(-left, -top);
matrix.postTranslate(left , top);
camera.restore();
int count = canvas.save();
canvas.concat(matrix);
return count;
}
代码示例来源:origin: Yalantis/Side-Menu.Android
@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);
}
代码示例来源:origin: jdsjlzx/LRecyclerView
@Override
public void draw(Canvas canvas, Paint paint) {
mMatrix.reset();
mCamera.save();
mCamera.rotateX(rotateX);
mCamera.rotateY(rotateY);
mCamera.getMatrix(mMatrix);
mCamera.restore();
mMatrix.preTranslate(-centerX(), -centerY());
mMatrix.postTranslate(centerX(), centerY());
canvas.concat(mMatrix);
Path path=new Path();
path.moveTo(getWidth()/5,getHeight()*4/5);
path.lineTo(getWidth()*4/5, getHeight()*4/5);
path.lineTo(getWidth()/2,getHeight()/5);
path.close();
canvas.drawPath(path, paint);
}
代码示例来源:origin: jdsjlzx/LRecyclerView
@Override
public void draw(Canvas canvas, Paint paint) {
mMatrix.reset();
mCamera.save();
mCamera.rotateX(rotateX);
mCamera.rotateY(rotateY);
mCamera.getMatrix(mMatrix);
mCamera.restore();
mMatrix.preTranslate(-centerX(), -centerY());
mMatrix.postTranslate(centerX(), centerY());
canvas.concat(mMatrix);
canvas.drawRect(new RectF(getWidth()/5,getHeight()/5,getWidth()*4/5,getHeight()*4/5),paint);
}
代码示例来源:origin: stackoverflow.com
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
代码示例来源: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: ybq/Android-SpinKit
@Override
public void draw(Canvas canvas) {
int tx = getTranslateX();
tx = tx == 0 ? (int) (getBounds().width() * getTranslateXPercentage()) : tx;
int ty = getTranslateY();
ty = ty == 0 ? (int) (getBounds().height() * getTranslateYPercentage()) : ty;
canvas.translate(tx, ty);
canvas.scale(getScaleX(), getScaleY(), getPivotX(), getPivotY());
canvas.rotate(getRotate(), getPivotX(), getPivotY());
if (getRotateX() != 0 || getRotateY() != 0) {
mCamera.save();
mCamera.rotateX(getRotateX());
mCamera.rotateY(getRotateY());
mCamera.getMatrix(mMatrix);
mMatrix.preTranslate(-getPivotX(), -getPivotY());
mMatrix.postTranslate(getPivotX(), getPivotY());
mCamera.restore();
canvas.concat(mMatrix);
}
drawSelf(canvas);
}
代码示例来源:origin: com.nineoldandroids/library
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);
}
代码示例来源:origin: kakajika/FragmentAnimations
camera.rotateY(rY);
camera.rotateZ(-rZ);
camera.getMatrix(m);
代码示例来源:origin: luhaoaimama1/zone-sdk
public CameraInvert rotateY_3D(float degrees) {
mode = RELATIVE_TO_SELF;
mCamera.rotateY(-degrees);
return this;
}
代码示例来源:origin: luhaoaimama1/zone-sdk
public CameraInvert rotateY_3D(float degrees, float pz) {
savePxy_Z(pz);
mCamera.rotateY(-degrees);
degrees3DX = 0;
degrees3DY = degrees;
return this;
}
代码示例来源:origin: OCNYang/PageTransformerHelp
protected static final float getOffsetXForRotation(float degrees, int width, int height) {
OFFSET_MATRIX.reset();
OFFSET_CAMERA.save();
OFFSET_CAMERA.rotateY(Math.abs(degrees));
OFFSET_CAMERA.getMatrix(OFFSET_MATRIX);
OFFSET_CAMERA.restore();
OFFSET_MATRIX.preTranslate(-width * 0.5f, -height * 0.5f);
OFFSET_MATRIX.postTranslate(width * 0.5f, height * 0.5f);
OFFSET_TEMP_FLOAT[0] = width;
OFFSET_TEMP_FLOAT[1] = height;
OFFSET_MATRIX.mapPoints(OFFSET_TEMP_FLOAT);
return (width - OFFSET_TEMP_FLOAT[0]) * (degrees > 0.0f ? 1.0f : -1.0f);
}
代码示例来源:origin: githubwing/compassView
private void rotateCanvas(Canvas canvas) {
mMatrix.reset();
mCamera.save();
mCamera.rotateX(mCanvasRotateX);
mCamera.rotateY(mCanvasRotateY);
mCamera.getMatrix(mMatrix);
mCamera.restore();
mMatrix.preTranslate(-mCenterX, -mCenterY);
mMatrix.postTranslate(mCenterX, mCenterY);
canvas.concat(mMatrix);
}
代码示例来源:origin: stackoverflow.com
@Override
public void drawPixmap3D(Pixmap pixmap, int x, int y, int r) {
Camera camera = mCamera;
int cx = pixmap.getWidth()/2;
camera.save();
camera.rotateY(r);
camera.getMatrix(mtx);
mtx.preTranslate(-cx, 0);
mtx.postTranslate(x, y);
camera.restore();
canvas.drawBitmap(((AndroidPixmap)pixmap).bitmap, mtx, this.paint);
}
代码示例来源:origin: yaozs/YzsBaseActivity
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
Matrix matrix = t.getMatrix();
Camera camera = new Camera();
camera.save();
camera.rotateY(720 * interpolatedTime);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-mCenterX, -mCenterY);
matrix.postTranslate(mCenterX, mCenterY);
}
}
代码示例来源:origin: liberty2015/3DViewPagerGallery
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
super.applyTransformation(interpolatedTime, t);
camera.save();
camera.rotateY(rotate*(interpolatedTime));
Matrix matrix=t.getMatrix();
camera.getMatrix(matrix);
matrix.preTranslate(-centerX,-centerY);
matrix.postTranslate(centerX,centerY);
camera.restore();
}
}
代码示例来源:origin: liberty2015/3DViewPagerGallery
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
super.applyTransformation(interpolatedTime, t);
camera.save();
camera.rotateY(-40*(interpolatedTime));
Matrix matrix=t.getMatrix();
camera.getMatrix(matrix);
matrix.preTranslate(-centerX,-centerY);
matrix.postTranslate(centerX,centerY);
camera.restore();
}
}
内容来源于网络,如有侵权,请联系作者删除!