Example usage for android.graphics Canvas drawPath

List of usage examples for android.graphics Canvas drawPath

Introduction

In this page you can find the example usage for android.graphics Canvas drawPath.

Prototype

public void drawPath(@NonNull Path path, @NonNull Paint paint) 

Source Link

Document

Draw the specified path using the specified paint.

Usage

From source file:android.support.v7.graphics.drawable.VectorDrawableCompat.java

@Override
public void draw(Canvas canvas) {
    Paint paint = new Paint();
    for (Pair<Path, Integer> pair : mPaths) {
        Path path = pair.first;/*w w w.j a va 2  s  . c  om*/
        int color = pair.second;
        paint.setColor(color);
        canvas.drawPath(path, paint);
    }
}

From source file:com.appsimobile.appsii.module.home.SunriseDrawable.java

private float drawArc(Canvas canvas, Rect bounds) {
    canvas.drawPath(mArc, mArcPaint);

    int minuteSinceStart = mNowMinutes - mRiseMinutes;
    int totalMinutes = mSetMinutes - mRiseMinutes;
    float pct = (minuteSinceStart / (float) totalMinutes);

    int r = bounds.right - mRightOffset;
    int l = bounds.left + mLeftOffset;

    int px = (int) (pct * (r - l));

    mClipRect.set(0, 0, l + px, bounds.bottom);
    canvas.save(Canvas.CLIP_SAVE_FLAG);
    canvas.clipRect(mClipRect);/*from  w  w  w. jav a 2 s  .  c o  m*/
    canvas.drawPath(mArcFill, mArcFillPaint);
    canvas.restore();

    return pct;
}

From source file:com.rks.musicx.misc.widgets.DiagonalLayout.java

@Override
protected void dispatchDraw(Canvas canvas) {
    int saveCount = canvas.saveLayer(0, 0, getWidth(), getHeight(), null, Canvas.ALL_SAVE_FLAG);

    super.dispatchDraw(canvas);

    paint.setXfermode(pdMode);//from w  w w  .j a va 2 s  .co  m
    canvas.drawPath(clipPath, paint);

    canvas.restoreToCount(saveCount);
    paint.setXfermode(null);
}

From source file:com.nextgis.maplibui.formcontrol.Sign.java

protected void drawSign(Canvas canvas, int bkColor, Paint paint) {
    canvas.drawColor(bkColor);/*from   w w  w  .jav  a 2  s .co m*/

    for (Path path : mPaths)
        canvas.drawPath(path, paint);
}

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  .j  a  v a 2s.  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;
}

From source file:com.ichi2.anki.Whiteboard.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.drawColor(0);//from ww w  .  ja v a2  s.  com
    canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
    canvas.drawPath(mPath, mPaint);
}

From source file:com.android.inputmethod.latin.setup.SetupStepIndicatorView.java

@Override
protected void onDraw(final Canvas canvas) {
    super.onDraw(canvas);
    final int xPos = (int) (getWidth() * mXRatio);
    final int height = getHeight();
    mIndicatorPath.rewind();//w w w.  j ava2s . com
    mIndicatorPath.moveTo(xPos, 0);
    mIndicatorPath.lineTo(xPos + height, height);
    mIndicatorPath.lineTo(xPos - height, height);
    mIndicatorPath.close();
    canvas.drawPath(mIndicatorPath, mIndicatorPaint);
}

From source file:jp.co.recruit_lifestyle.android.widget.ColoringLoadingView.java

@Override
protected void onDraw(Canvas canvas) {
    canvas.drawPath(mBackgroundPath.getShadowPath(), mShadowPaint);
    canvas.drawPath(mBackgroundPath.getBackgroundPath(), mBackgroundPaint);

    if (isHandWriting) {
        //Auto/*from  w w w.ja  v a 2 s  . c  o m*/
        canvas.drawPath(mCharacterPath, mCharacterPaint);
        canvas.drawPath(mLoadingPath, mLoadingPaint);
        canvas.drawPath(mPencilPath.getPencilPath(mCurrentPoint), mPencilPaint);
    } else {
        //Touch
        canvas.drawPath(mColoringPath, mColoringPaint);
        canvas.drawPath(mCharacterPath, mCharacterPaint);
        canvas.drawPath(mPencilPath.getPencilPath(mCurrentTouchPoint), mPencilPaint);
        canvas.drawPath(mLoadingPath, mLoadingPaint);
    }
}

From source file:org.telegram.ui.Cells.AboutLinkCell.java

@Override
protected void onDraw(Canvas canvas) {
    canvas.save();/*w ww  .  ja va  2s . com*/
    canvas.translate(textX = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 71),
            textY = AndroidUtilities.dp(8));
    if (pressedLink != null) {
        canvas.drawPath(urlPath, urlPaint);
    }
    try {
        if (textLayout != null) {
            textLayout.draw(canvas);
        }
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
    canvas.restore();
}

From source file:com.breel.wearables.shadowclock.graphics.ShapeShadow.java

public void drawShape(Canvas canvas) {
    canvas.drawPath(shapePath, shapePathPaint);
    if (DEBUG) {//from ww w .j a  va 2  s . c  o  m
        canvas.drawPath(boundsPath, boundsPathPaint);
        canvas.drawCircle(medX, medY, 5, gradientHelperPaint);
    }

}