Camera实现动画Papaer效果
来源:互联网 发布:ubuntu中文语言包 apt 编辑:程序博客网 时间:2024/04/30 07:55
https://github.com/Ramotion/folding-cell-android
paperw work分析
package com.ramotion.foldingcell.animations;import android.graphics.Camera;import android.graphics.Matrix;import android.view.animation.Animation;import android.view.animation.Interpolator;import android.view.animation.Transformation;/** * Main piece of fold animation */public class FoldAnimation extends Animation { public enum FoldAnimationMode { FOLD_UP, UNFOLD_DOWN, FOLD_DOWN, UNFOLD_UP } private final FoldAnimationMode mFoldMode; private float mFromDegrees; private float mToDegrees; private float mCenterX; private float mCenterY; private Camera mCamera; public FoldAnimation(FoldAnimationMode foldMode, long duration) { this.mFoldMode = foldMode; this.setFillAfter(true); this.setDuration(duration); } public FoldAnimation withAnimationListener(AnimationListener animationListener) { this.setAnimationListener(animationListener); return this; } public FoldAnimation withStartOffset(int offset) { this.setStartOffset(offset); return this; } public FoldAnimation withInterpolator(Interpolator interpolator) { if (interpolator != null) { this.setInterpolator(interpolator); } return this; } @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); this.mCamera = new Camera(); this.mCenterX = width / 2; switch (mFoldMode) { case FOLD_UP: this.mCenterY = 0; this.mFromDegrees = 0; this.mToDegrees = 90; break; case FOLD_DOWN: this.mCenterY = height; this.mFromDegrees = 0; this.mToDegrees = -90; break; case UNFOLD_UP: this.mCenterY = height; this.mFromDegrees = -90; this.mToDegrees = 0; break; case UNFOLD_DOWN: this.mCenterY = 0; this.mFromDegrees = 90; this.mToDegrees = 0; break; default: throw new IllegalStateException("Unknown animation mode."); } } @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); } @Override public String toString() { return "FoldAnimation{" + "mFoldMode=" + mFoldMode + ", mFromDegrees=" + mFromDegrees + ", mToDegrees=" + mToDegrees + '}'; }}
0 0
- Camera实现动画Papaer效果
- jQuery动画效果实现
- iPhone 实现动画效果
- jquery实现动画效果
- silverlight 实现动画效果
- jQuery实现动画效果
- UIView实现动画效果
- Android动画效果实现
- jQuery实现动画效果
- Fragment 实现动画效果
- cocos2d实现动画效果
- android实现动画效果
- UIView实现动画效果
- 动画效果实现
- jquery实现动画效果
- js实现动画效果
- JQuery实现动画效果
- React实现动画效果
- NYOJ 42 一笔画问题(欧拉定理&&并查集)
- 特殊的棋子(bfs)(北理16校赛)
- Android开发者上手宝典(三)
- Android笔记-活动
- Java 实现 SSH 协议的客户端登录认证方式
- Camera实现动画Papaer效果
- 点击Viewflipper图片跳转到对应的页面代码
- “高考减招事件”引发在线教育思考 视频云助力行业攻难
- 开心的mdd-矩阵链乘
- 安卓的屏幕适配问题
- 如何打jar包和运行jar包
- Java多线程发展简史
- 编程过程中遇到的python问题与解决方法_来自网络
- 关于 Android 进程的简介