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

The following examples show how to use android.graphics.Matrix#postSkew() . 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: ObjectPropertyAnimActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
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
Source File: MatrixActivity.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
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
Source File: PropertyAnimation06.java    From cogitolearning-examples with MIT License 6 votes vote down vote up
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 File: DrawElement.java    From cidrawing with 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 File: MatrixMethod.java    From zone-sdk with 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
Source File: ImagePipelineBitmapFactoryFragment.java    From fresco with MIT License 4 votes vote down vote up
private static Matrix getMatrix(float skewX, float skewY, float degrees) {
  Matrix matrix = new Matrix();
  matrix.postSkew(skewX, skewY);
  matrix.postRotate(degrees);
  return matrix;
}