Example usage for android.graphics Matrix postSkew

List of usage examples for android.graphics Matrix postSkew

Introduction

In this page you can find the example usage for android.graphics Matrix postSkew.

Prototype

public boolean postSkew(float kx, float ky, float px, float py) 

Source Link

Document

Postconcats the matrix with the specified skew.

Usage

From source file:com.artioml.practice.activities.LicenseActivity.java

public BitmapDrawable drawParallelogramLine(int width) {
    Matrix matrix = new Matrix();
    Path path = new Path();
    path.addRect(0, 0, (4 * width) / 40, (4 * width) / 200, Path.Direction.CW);
    Path pathStamp = new Path();
    Paint p;/*from ww w.ja v a 2 s  .co  m*/
    Bitmap bitmap;

    p = new Paint(Paint.ANTI_ALIAS_FLAG);
    p.setStyle(Paint.Style.FILL);

    bitmap = Bitmap.createBitmap(width / 4, width / 80 * 2 + (4 * width) / 200, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    p.setColor(ContextCompat.getColor(this, R.color.colorPrimaryLight));

    matrix.reset();
    matrix.setTranslate(0, 0);
    matrix.postSkew(-1f, 0.0f, 0, (4 * width) / 200);
    path.transform(matrix, pathStamp);
    canvas.drawPath(pathStamp, p);

    p.setColor(ContextCompat.getColor(this, R.color.colorAccent));

    matrix.reset();
    matrix.setTranslate(width / 8, 0);
    matrix.postSkew(-1f, 0.0f, width / 8, (4 * width) / 200);
    path.transform(matrix, pathStamp);
    canvas.drawPath(pathStamp, p);

    BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), bitmap);
    bitmapDrawable.setTileModeX(Shader.TileMode.REPEAT);

    return bitmapDrawable;
}