Java Code Examples for android.graphics.Matrix#postSkew()

The following examples show how to use android.graphics.Matrix#postSkew() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
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();
}
 
Example 2
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);
}
 
Example 3
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();
  
}
 
Example 4
Source Project: cidrawing   File: DrawElement.java    License: Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 5
Source Project: zone-sdk   File: MatrixMethod.java    License: MIT License 5 votes vote down vote up
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();
    }
 
Example 6
private static Matrix getMatrix(float skewX, float skewY, float degrees) {
  Matrix matrix = new Matrix();
  matrix.postSkew(skewX, skewY);
  matrix.postRotate(degrees);
  return matrix;
}