android.graphics.Camera.rotateX()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中android.graphics.Camera.rotateX()方法的一些代码示例,展示了Camera.rotateX()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Camera.rotateX()方法的具体详情如下:
包路径:android.graphics.Camera
类名称:Camera
方法名:rotateX

Camera.rotateX介绍

暂无

代码示例

代码示例来源: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: Ramotion/folding-cell-android

@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);
}

代码示例来源: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: AigeStudio/WheelPicker

mCamera.rotateX(degree);
mCamera.getMatrix(mMatrixRotate);
mCamera.restore();

代码示例来源:origin: jdsjlzx/LRecyclerView

@Override
public void draw(Canvas canvas, Paint paint) {
  mMatrix.reset();
  mCamera.save();
  mCamera.rotateX(degress);
  mCamera.getMatrix(mMatrix);
  mCamera.restore();
  mMatrix.preTranslate(-centerX(), -centerY());
  mMatrix.postTranslate(centerX(), centerY());
  canvas.concat(mMatrix);
  float radius=getWidth()/10;
  canvas.drawCircle(getWidth()/4,radius*2,radius,paint);
  canvas.drawCircle(getWidth()*3/4,radius*2,radius,paint);
  canvas.drawCircle(radius,getHeight()-2*radius,radius,paint);
  canvas.drawCircle(getWidth()/2,getHeight()-2*radius,radius,paint);
  canvas.drawCircle(getWidth()-radius,getHeight()-2*radius,radius,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: ImmortalZ/StereoView

private void drawScreen(Canvas canvas, int i, long drawingTime) {
  int curScreenY = mHeight * i;
  //屏幕中不显示的部分不进行绘制
  if (getScrollY() + mHeight < curScreenY) {
    return;
  }
  if (curScreenY < getScrollY() - mHeight) {
    return;
  }
  float centerX = mWidth / 2;
  float centerY = (getScrollY() > curScreenY) ? curScreenY + mHeight : curScreenY;
  float degree = mAngle * (getScrollY() - curScreenY) / mHeight;
  if (degree > 90 || degree < -90) {
    return;
  }
  canvas.save();
  mCamera.save();
  mCamera.rotateX(degree);
  mCamera.getMatrix(mMatrix);
  mCamera.restore();
  mMatrix.preTranslate(-centerX, -centerY);
  mMatrix.postTranslate(centerX, centerY);
  canvas.concat(mMatrix);
  drawChild(canvas, getChildAt(i), drawingTime);
  canvas.restore();
}

代码示例来源: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.translate(0, 0, mTranslationZ);
camera.rotateX(rX);
camera.rotateY(rY);
camera.rotateZ(-rZ);

代码示例来源:origin: luhaoaimama1/zone-sdk

@Override
  public void rotateX(float deg) {
    super.rotateX(-deg);
  }
}

代码示例来源:origin: luhaoaimama1/zone-sdk

public CameraInvert rotateX_3D(float degrees) {
    mode = RELATIVE_TO_SELF;
    mCamera.rotateX(-degrees);
    return this;
//        return rotateX_3D(degrees,0);
  }

代码示例来源:origin: luhaoaimama1/zone-sdk

public CameraInvert rotateX_3D(float degrees, float pz) {
  savePxy_Z(pz);
  mCamera.rotateX(-degrees);
  degrees3DY =0;
  degrees3DX = degrees;
  return this;
}

代码示例来源:origin: xenione/tab-digit

public static void rotateX(Matrix matrix, int alpha) {
  synchronized (camera) {
    camera.save();
    camera.rotateX(alpha);
    camera.getMatrix(matrix);
    camera.restore();
  }
}

代码示例来源: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: JustinRoom/WheelViewDemo

@Override
  protected void onDraw(Canvas canvas) {
    float cx = getWidth() / 2.0f;
    float cy = getHeight() / 2.0f;
    matrix.reset();
    camera.save();
    camera.rotateX(angle);
    camera.getMatrix(matrix);
    camera.restore();

    matrix.postTranslate(cx, cy);
    matrix.preTranslate(-cx, -cy);

    canvas.concat(matrix);
    super.onDraw(canvas);
  }
}

代码示例来源:origin: stackoverflow.com

matrix = new Matrix();

Camera camera = new Camera();
camera.save();
camera.rotateX(45f);
camera.getMatrix(matrix);
camera.restore();

代码示例来源:origin: wangxp423/ViewExercise

private void set3DMatrix() {
  mCameraMatrix.reset();
  mCamera.save();
  mCamera.rotateX(mCameraRotateX);
  mCamera.rotateY(mCameraRotateY);
  mCamera.getMatrix(mCameraMatrix);
  mCamera.restore();
  //camera默认旋转是View左上角为旋转中心
  //所以动作之前要,设置矩阵位置 -mTextHeight-mOutSideRadius
  mCameraMatrix.preTranslate(-getWidth() / 2, -getHeight() / 2);
  //动作之后恢复位置
  mCameraMatrix.postTranslate(getWidth() / 2, getHeight() / 2);
  //基于 Canvas 当前的变换,叠加上 Matrix 中的变换。
  mCanvas.concat(mCameraMatrix);
}

代码示例来源:origin: ChaosOctopus/ChaosCompass

/**
 * 设置camera相关
 */
private void set3DMetrix() {
  mCameraMatrix.reset();
  mCamera.save();
  mCamera.rotateX(mCameraRotateX);
  mCamera.rotateY(mCameraRotateY);
  mCamera.getMatrix(mCameraMatrix);
  mCamera.restore();
  //camera默认旋转是View左上角为旋转中心
  //所以动作之前要,设置矩阵位置 -mTextHeight-mOutSideRadius
  mCameraMatrix.preTranslate(-getWidth()/2,-getHeight()/2);
  //动作之后恢复位置
  mCameraMatrix.postTranslate(getWidth()/2,getHeight()/2);
  mCanvas.concat(mCameraMatrix);
}

代码示例来源:origin: wangxp423/ViewExercise

private void set3DMatrix(Canvas canvas) {
  mCameraMatrix.reset();
  mCamera.save();
  mCamera.rotateX(mCameraRotateX);
  mCamera.rotateY(mCameraRotateY);
  mCamera.getMatrix(mCameraMatrix);
  mCamera.restore();
  //camera默认旋转是View左上角为旋转中心
  //所以动作之前要,设置矩阵位置 -mTextHeight-mOutSideRadius
  mCameraMatrix.preTranslate(-getWidth() / 2, -getHeight() / 2);
  //动作之后恢复位置
  mCameraMatrix.postTranslate(getWidth() / 2, getHeight() / 2);
  //基于 Canvas 当前的变换,叠加上 Matrix 中的变换。
  canvas.concat(mCameraMatrix);
}

相关文章