android.graphics.Camera Java Examples

The following examples show how to use android.graphics.Camera. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecyclerWheelPicker.java    From RecyclerWheelPicker with Apache License 2.0 6 votes vote down vote up
private void init(Context context) {
    initSound();

    setOverScrollMode(OVER_SCROLL_NEVER);
    setHasFixedSize(true);

    mDecorationPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mUnitTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mDecorationRect = new Rect();
    mDecoration = new DefaultDecoration();

    mAdapter = new WheelAdapter(context);
    super.setAdapter(mAdapter);
    mLayoutManager = new WheelPickerLayoutManager(this);
    super.setLayoutManager(mLayoutManager);
    new LinearSnapHelper().attachToRecyclerView(this);

    mCamera = new Camera();
    mMatrix = new Matrix();
}
 
Example #2
Source File: RotateView.java    From WanAndroid with Apache License 2.0 6 votes vote down vote up
public RotateView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.RotateView);
    BitmapDrawable bitmapDrawable = (BitmapDrawable) array.getDrawable(R.styleable.RotateView_viewBackgound2);
    array.recycle();

    if (bitmapDrawable != null) {

        bitmap = bitmapDrawable.getBitmap();
        byte[] bytes = BitmapUtil.bitmap2Bytes(bitmap);
        bitmap = BitmapUtil.resizeBitmapBytes(bytes);
    }else {
        bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
    }

    camera = new Camera();
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    float newZ = -metrics.density * 6;
    camera.setLocation(0, 0, newZ);
}
 
Example #3
Source File: EBrowserAnimation.java    From appcan-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #4
Source File: RotationDrawStrategy.java    From styT with Apache License 2.0 6 votes vote down vote up
/**
 * 根据角度绘制图标的类
 * @param canvas 画布
 * @param fraction 完成时间百分比
 * @param icon 图标
 * @param width view宽度
 * @param height view高度
 */
private void drawIconOne(Canvas canvas, float fraction, Bitmap icon, int width, int height) {
    Camera camera = new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    canvas.save();
    int centerX = width / 2;
    int centerY = height / 2 - 200;
    int x = centerX - icon.getWidth()/2;
    int y = centerY - icon.getHeight()/2;
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);
    canvas.concat(matrix);
    canvas.clipRect(x, y, x + icon.getWidth() * fraction * 0.5f, y + icon.getHeight() * fraction * 0.5f);
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180);
    camera.rotateY(-180);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();
}
 
Example #5
Source File: Rotate3dAnimation.java    From FragmentRigger with MIT License 6 votes vote down vote up
@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);
}
 
Example #6
Source File: WheelView.java    From WheelPicker with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化并设置默认值
 *
 * @param context 上下文
 */
private void initValue(Context context) {
    ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mMaxFlingVelocity = viewConfiguration.getScaledMaximumFlingVelocity();
    mMinFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
    mScroller = new Scroller(context);
    mDrawRect = new Rect();
    mCamera = new Camera();
    mMatrix = new Matrix();
    if (!isInEditMode()) {
        mSoundHelper = SoundHelper.obtain();
        initDefaultVolume(context);
    }
    calculateTextSize();
    updateTextAlign();
}
 
Example #7
Source File: SphereLayout.java    From SphereLayout with MIT License 6 votes vote down vote up
public SphereLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SphereLayout);
    mRadius = a.getDimensionPixelSize(R.styleable.SphereLayout_radius, 0);//球体半径
    mOrientation = a.getInt(R.styleable.SphereLayout_snapOrientation, HORIZONTAL);//标记位于背面的视图是以Y轴水平翻转到达正面 或是以X轴竖直翻转可到达正面
    mHideBack = a.getBoolean(R.styleable.SphereLayout_hideBack, false);//是否隐藏处在背面的布局
    a.recycle();
    mCenter = new Point();
    mCamera = new Camera();
    mDependencyOffset = new int[2];
    //mCamera.setLocation(0, 0, -20);
    mMatrix = new Matrix();
    mPositiveChildren = new ArrayList<>();//depth为正的childview集合
    mNegativeChildren = new ArrayList<>();//depth为负的childview集合
    mDensity = getResources().getDisplayMetrics().density;
}
 
Example #8
Source File: RotationDrawStrategy.java    From FancyView with Apache License 2.0 6 votes vote down vote up
/**
 * 根据角度绘制图标的类
 * @param canvas 画布
 * @param fraction 完成时间百分比
 * @param icon 图标
 * @param width view宽度
 * @param height view高度
 */
private void drawIconOne(Canvas canvas, float fraction, Bitmap icon, int width, int height) {
    Camera camera = new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    canvas.save();
    int centerX = width / 2;
    int centerY = height / 2 - 200;
    int x = centerX - icon.getWidth()/2;
    int y = centerY - icon.getHeight()/2;
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);
    canvas.concat(matrix);
    canvas.clipRect(x, y, x + icon.getWidth() * fraction * 0.5f, y + icon.getHeight() * fraction * 0.5f);
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180);
    camera.rotateY(-180);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();
}
 
Example #9
Source File: Rotate3dAnimation.java    From Android-tv-widget with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #10
Source File: Rotate3d.java    From FragmentRigger with MIT License 6 votes vote down vote up
@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);
  }
 
Example #11
Source File: Rotate3dAnimation.java    From android-tv-launcher with MIT License 6 votes vote down vote up
@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);
}
 
Example #12
Source File: Rotate3dAnimation.java    From BookLoadingView with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #13
Source File: Rotate3dAnimation.java    From AndroidTVWidget with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #14
Source File: Rotate3dAnimation.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@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);
}
 
Example #15
Source File: Rotate3DAnimation.java    From Jreader with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 执行顺序 matrix.preTranslate() -->  camera.rotateY(degrees) -->   matrix.postTranslate() -->   matrix.postScale()
 * @param interpolatedTime
 * @param t
 */
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    float degrees = mReverse ? mToDegrees + (mFromDegrees - mToDegrees) * interpolatedTime : mFromDegrees + (mToDegrees - mFromDegrees) * interpolatedTime;
    final Matrix matrix = t.getMatrix();

    final Camera camera = mCamera;

    camera.save();

    camera.rotateY(degrees);

    camera.getMatrix(matrix);
    camera.restore();

          //  matrix.preTranslate(-mPivotXValue, 0);      //在进行rotateY之前需要移动物体,让物体左边与Y轴对齐
          //  matrix.postTranslate(mPivotXValue, 0);      //还原物体位置

    if (mReverse) {
        matrix.postScale(1 + (scaleTimes - 1) * (1.0f - interpolatedTime), 1 + (scaleTimes - 1) * (1.0f - interpolatedTime), mPivotX - mPivotXValue , mPivotY - mPivotYValue);
    } else {
       // matrix.postScale(1 + (scaleTimes - 1) * interpolatedTime, 1 + (scaleTimes - 1) * interpolatedTime, mPivotX, mPivotY);
        matrix.postScale(1 + (scaleTimes - 1) * interpolatedTime, 1 + (scaleTimes - 1) * interpolatedTime, mPivotX - mPivotXValue , mPivotY - mPivotYValue );
    }
}
 
Example #16
Source File: AutoTextView.java    From NewXmPluginSDK with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #17
Source File: Rotate3dAnimation.java    From SUtil with Artistic License 2.0 5 votes vote down vote up
@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();
    float[] mValues = {0, 0, 0, 0, 0, 0, 0, 0, 0};
    matrix.getValues(mValues);            //获取数值
    mValues[6] = mValues[6] / scale;      //数值修正
    matrix.setValues(mValues);            //重新赋值

    matrix.preTranslate(-centerX, -centerY);
    matrix.postTranslate(centerX, centerY);
}
 
Example #18
Source File: Rotate3dAnimation.java    From pe-protector-moe with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
    super.initialize(width, height, parentWidth, parentHeight);
    mCamera = new Camera();
    mPivotX = resolveSize(mPivotXType, mPivotXValue, width, parentWidth);
    mPivotY = resolveSize(mPivotYType, mPivotYValue, height, parentHeight);
}
 
Example #19
Source File: MultiChoicesCircleButton.java    From MultiChoicesCircleButton with MIT License 5 votes vote down vote up
public MultiChoicesCircleButton(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MultiChoicesCircleButton);
    mIcon = typedArray.getDrawable(R.styleable.MultiChoicesCircleButton_mccb_icon);
    mParallaxEnabled = typedArray.getBoolean(R.styleable.MultiChoicesCircleButton_mccb_enableParallax, true);
    mCollapseRadius = typedArray.getDimension(R.styleable.MultiChoicesCircleButton_mccb_collapseRadius, dp2px(40));
    mExpandRadius = typedArray.getDimension(R.styleable.MultiChoicesCircleButton_mccb_expandRadius, dp2px(120));
    mText = typedArray.getString(R.styleable.MultiChoicesCircleButton_mccb_text);
    mTextSize = typedArray.getDimension(R.styleable.MultiChoicesCircleButton_mccb_textSize, sp2px(35));
    mTextColor = typedArray.getColor(R.styleable.MultiChoicesCircleButton_mccb_textColor, Color.WHITE);
    mButtonColor = typedArray.getColor(R.styleable.MultiChoicesCircleButton_mccb_buttonColor, Color.parseColor("#FC516A"));
    mDuration = typedArray.getInt(R.styleable.MultiChoicesCircleButton_mccb_duration, 200);
    mItemRadius = typedArray.getDimension(R.styleable.MultiChoicesCircleButton_mccb_itemRadius, dp2px(20));
    mItemDistanceToCentre = typedArray.getDimension(R.styleable.MultiChoicesCircleButton_mccb_itemDistanceToCentre, mExpandRadius * 2 / 3);
    mItemBackgroundColor = typedArray.getColor(R.styleable.MultiChoicesCircleButton_mccb_itemBackgroundColor, Color.WHITE);
    mShowBackgroundShadowEnable = typedArray.getBoolean(R.styleable.MultiChoicesCircleButton_mccb_showBackgroundShadow, true);
    mBackgroundShadowColor = typedArray.getColor(R.styleable.MultiChoicesCircleButton_mccb_backgroundShadowColor, Color.parseColor("#bb757575"));
    typedArray.recycle();

    initPaint();
    initAnimation();
    if (mParallaxEnabled) {
        mCamera = new Camera();
        mMatrix = new Matrix();
    }
    if (mShowBackgroundShadowEnable) {
        backgroundEvaluator = new ArgbEvaluator();
    }
}
 
Example #20
Source File: Rotate3dAnimation.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #21
Source File: Rotate3dAnimation.java    From KAlertDialog with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
    super.initialize(width, height, parentWidth, parentHeight);
    camera = new Camera();
    pivotX = resolveSize(mPivotXType, mPivotXValue, width, parentWidth);
    pivotY = resolveSize(mPivotYType, mPivotYValue, height, parentHeight);
}
 
Example #22
Source File: UEAnimatorProxy.java    From Auie with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #23
Source File: Rotate3dAnimation.java    From HaiNaBaiChuan with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
    super.initialize(width, height, parentWidth, parentHeight);
    mCamera = new Camera();
    mPivotX = resolveSize(mPivotXType, mPivotXValue, width, parentWidth);
    mPivotY = resolveSize(mPivotYType, mPivotYValue, height, parentHeight);
}
 
Example #24
Source File: DotImageView.java    From FloatMenuSample with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void init() {
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setTextSize(sp2px(10));
    mPaint.setStyle(Paint.Style.FILL);

    mPaintBg = new Paint();
    mPaintBg.setAntiAlias(true);
    mPaintBg.setStyle(Paint.Style.FILL);
    mPaintBg.setColor(mBgColor);//60% 黑色背景 (透明度 40%)

    mCamera = new Camera();
    mMatrix = new Matrix();
}
 
Example #25
Source File: Rotate3DCard.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    super.applyTransformation(interpolatedTime, t);
    Matrix matrix = t.getMatrix();
    Camera camera = new Camera();
    camera.save();
    camera.rotateY(-180 * interpolatedTime);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-mcenterX,-mcenterY);
    matrix.postTranslate(mcenterX,mcenterY);
}
 
Example #26
Source File: Rotate3dAnimation.java    From AndroidPlayground with MIT License 5 votes vote down vote up
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
    super.initialize(width, height, parentWidth, parentHeight);
    this.width = width / 2;
    this.height = height / 2;
    camera = new Camera();
}
 
Example #27
Source File: RotateActivityFrom90.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    super.applyTransformation(interpolatedTime, t);
    Matrix matrix = t.getMatrix();
    Camera camera = new Camera();
    camera.save();
    camera.rotateY(90-90 * interpolatedTime);
    camera.getMatrix(matrix);
    camera.restore();
    matrix.preTranslate(-mcenterX,-mcenterY);
    matrix.postTranslate(mcenterX,mcenterY);
}
 
Example #28
Source File: FlipCard.java    From FlipGank with Apache License 2.0 5 votes vote down vote up
public FlipCard(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mScrimPaint = new Paint();
    mCamera = new Camera();
    mMatrix = new Matrix();
}
 
Example #29
Source File: FlipDrawable.java    From Plumble with GNU General Public License v3.0 5 votes vote down vote up
public FlipDrawable(Drawable from, Drawable to) {
    super(new Drawable[] { from, to });
    mFrom = from;
    mTo = to;
    mCamera = new Camera();
    mRotate = 0;
}
 
Example #30
Source File: AnimatorProxy.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
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);
}