android.graphics.Camera类的使用及代码示例

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

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

Camera介绍

暂无

代码示例

代码示例来源: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: ybq/Android-SpinKit

public Sprite() {
  mCamera = new Camera();
  mMatrix = new Matrix();
}

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

@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
  super.initialize(width, height, parentWidth, parentHeight);
  this.mCamera = new Camera();
  mCamera.setLocation(0, 0, -mCameraHeight);

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

@Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    canvas.save();
    camera.save();
    camera.rotateX(30);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.drawBitmap(bitmap, point1.x, point1.y, paint);
    canvas.restore();

    canvas.save();
    camera.save();
    camera.rotateY(30);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.drawBitmap(bitmap, point2.x, point2.y, paint);
    canvas.restore();
  }
}

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

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

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

public static class CubeRotate extends Animation {

  private Camera mCamera;

  @Override
  public void initialize(int width, int height, int parentWidth, int parentHeight) {
    super.initialize(width, height, parentWidth, parentHeight);
    mCamera.setLocation(width, height * .5F, 0);
  }

  @Override
  protected void applyTransformation(float interpolatedTime, Transformation t) {

    mCamera.rotateY(90f * interpolatedTime);
    mCamera.getMatrix(t.getMatrix());
  }
}

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

public CameraInvert rotateY_3D(float degrees) {
  mode = RELATIVE_TO_SELF;
  mCamera.rotateY(-degrees);
  return this;
}

代码示例来源: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: luhaoaimama1/zone-sdk

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

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

@Override
public void rotateY(float deg) {
  super.rotateY(-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

private CameraInvert translate_(float x, float y, float z) {
  mCamera.translate(x, -y, -z);
  return this;
}

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

public BallPulseRiseIndicator(){
  mCamera=new Camera();
  mMatrix=new Matrix();
}

代码示例来源: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: luhaoaimama1/zone-sdk

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

代码示例来源: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);
}

相关文章