android.graphics.Matrix#postSkew ( )源码实例Demo

下面列出了android.graphics.Matrix#postSkew ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public void startSkewAnimation(View v) {
    float scale = (float)mShowAnimIV.getHeight()/(float)mShowAnimIV.getDrawable().getIntrinsicHeight();
    Matrix from = new Matrix();
    from.setScale(scale, scale);
    from.postSkew(-0.5f, 0.0f);
    Matrix to = new Matrix(mShowAnimIV.getMatrix());
    to.setScale(scale, scale);
    to.postSkew(0.5f, 0.0f);

    mShowAnimIV.setScaleType(ImageView.ScaleType.MATRIX);
    Matrix start = new Matrix();
    start.setScale(scale, scale);
    mShowAnimIV.setImageMatrix(start);

    ObjectAnimator objectAnimator = ObjectAnimator.ofObject(mShowAnimIV, "imageMatrix", new MatrixEvaluator(), from, to);
    objectAnimator.setDuration(C.Int.ANIM_DURATION);
    objectAnimator.setRepeatCount(5);
    objectAnimator.setRepeatMode(ObjectAnimator.REVERSE);
    objectAnimator.start();
}
 
private void updateMatrix(int action) {
	Matrix matrix = new Matrix();

	switch (action) {
	case ACTION_ROTATE:
		matrix.postRotate(45, 450, 450);
		break;
	case ACTION_TRANSLATE:
		matrix.postTranslate(250, 250);
		break;
	case ACTION_SCALE:
		matrix.postScale(1 / 2f, 2, 100, 100);
		break;
	case ACTION_SKEW:
		matrix.postSkew(0.2f, 0.2f, 100, 100);
		break;
	default:
		break;
	}

	mImageView.setImageMatrix(matrix);
}
 
public void startSkewAnimation(View view)
{
  ImageView image = (ImageView)findViewById(R.id.some_image);

  float scale = (float)image.getHeight()/(float)image.getDrawable().getIntrinsicHeight();
  Matrix from = new Matrix();
  from.setScale(scale, scale);
  from.postSkew(-0.5f, 0.0f);
  Matrix to = new Matrix(image.getMatrix());
  to.setScale(scale, scale);
  to.postSkew(0.5f, 0.0f);
  
  image.setScaleType(ScaleType.MATRIX);
  Matrix start = new Matrix();
  start.setScale(scale, scale);
  image.setImageMatrix(start);
  
  ObjectAnimator anim = ObjectAnimator.ofObject(image, "imageMatrix", new MatrixEvaluator(), from, to);
  anim.setDuration(500);
  anim.setRepeatCount(5);
  anim.setRepeatMode(ObjectAnimator.REVERSE);
  anim.start();
  
}
 
源代码4 项目: cidrawing   文件: DrawElement.java
@Override
public void skew(float kx, float ky, float px, float py) {
    Matrix m = new Matrix();
    m.postSkew(kx, ky, px, py);
    applyMatrixForData(m);
    updateBoundingBox();
}
 
源代码5 项目: zone-sdk   文件: MatrixMethod.java
private void skew(Canvas canvas, RectF rect,float kx, float ky,int color) {
        canvas.save();
        Matrix skaw=new Matrix();
//        skaw.postTranslate(100,0);
        //Xnew=考虑坐标系远点变换,最后加上(xT,yT) +(xT*ky,yT*kx)
        //Ynew=Yold+tY+kx*tY;
        skaw.postSkew(kx,ky);
        canvas.concat(skaw);
        paintStorke.setColor(color);
        paintStorke.setAlpha(255/2);
        canvas.drawRect(rect,paintStorke);
        canvas.restore();
    }
 
private static Matrix getMatrix(float skewX, float skewY, float degrees) {
  Matrix matrix = new Matrix();
  matrix.postSkew(skewX, skewY);
  matrix.postRotate(degrees);
  return matrix;
}