Search in sources :

Example 71 with Paint

use of android.graphics.Paint in project UltimateAndroid by cymcsg.

the class CirclesDrawable method initCirclesProgress.

private void initCirclesProgress(int[] colors) {
    initColors(colors);
    mPath = new Path();
    Paint basePaint = new Paint();
    basePaint.setAntiAlias(true);
    mFstHalfPaint = new Paint(basePaint);
    mScndHalfPaint = new Paint(basePaint);
    mAbovePaint = new Paint(basePaint);
    setColorFilter(mColorFilter);
}
Also used : Path(android.graphics.Path) Paint(android.graphics.Paint)

Example 72 with Paint

use of android.graphics.Paint in project UltimateAndroid by cymcsg.

the class RippleDrawable method drawRippleLayer.

private int drawRippleLayer(Canvas canvas, Rect bounds, PorterDuffXfermode mode) {
    boolean drewRipples = false;
    int restoreToCount = -1;
    int restoreTranslate = -1;
    // Draw ripples and update the animating ripples array.
    final int count = mExitingRipplesCount;
    final Ripple[] ripples = mExitingRipples;
    for (int i = 0; i <= count; i++) {
        final Ripple ripple;
        if (i < count) {
            ripple = ripples[i];
        } else if (mRipple != null) {
            ripple = mRipple;
        } else {
            continue;
        }
        // first. This will merge SRC_OVER (directly) onto the canvas.
        if (restoreToCount < 0) {
            final Paint maskingPaint = getMaskingPaint(mode);
            final int color = mColor.getColorForState(getState(), Color.TRANSPARENT);
            final int alpha = Color.alpha(color);
            maskingPaint.setAlpha(alpha / 2);
            // Translate the canvas to the current hotspot bounds.
            restoreTranslate = canvas.save();
            canvas.translate(mHotspotBounds.exactCenterX(), mHotspotBounds.exactCenterY());
        }
        drewRipples |= ripple.draw(canvas, getRipplePaint());
    }
    // Always restore the translation.
    if (restoreTranslate >= 0) {
        canvas.restoreToCount(restoreTranslate);
    }
    // If we created a layer with no content, merge it immediately.
    if (restoreToCount >= 0 && !drewRipples) {
        canvas.restoreToCount(restoreToCount);
        restoreToCount = -1;
    }
    return restoreToCount;
}
Also used : Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 73 with Paint

use of android.graphics.Paint in project UltimateAndroid by cymcsg.

the class IconPainter method init.

private void init() {
    paint = new Paint();
    paint.setAntiAlias(true);
    initBitmap();
}
Also used : Paint(android.graphics.Paint)

Example 74 with Paint

use of android.graphics.Paint in project UltimateAndroid by cymcsg.

the class MaterialTab method getTextLenght.

private int getTextLenght() {
    String textString = text.getText().toString();
    Rect bounds = new Rect();
    Paint textPaint = text.getPaint();
    textPaint.getTextBounds(textString, 0, textString.length(), bounds);
    return bounds.width();
}
Also used : Rect(android.graphics.Rect) Paint(android.graphics.Paint)

Example 75 with Paint

use of android.graphics.Paint in project UltimateAndroid by cymcsg.

the class TitlePageIndicator method calculateAllBounds.

/**
     * Calculate views bounds and scroll them according to the current index
     *
     * @param paint
     * @return
     */
private ArrayList<Rect> calculateAllBounds(Paint paint) {
    ArrayList<Rect> list = new ArrayList<Rect>();
    //For each views (If no values then add a fake one)
    final int count = mViewPager.getAdapter().getCount();
    final int width = getWidth();
    final int halfWidth = width / 2;
    for (int i = 0; i < count; i++) {
        Rect bounds = calcBounds(i, paint);
        int w = bounds.right - bounds.left;
        int h = bounds.bottom - bounds.top;
        bounds.left = (int) (halfWidth - (w / 2f) + ((i - mCurrentPage - mPageOffset) * width));
        bounds.right = bounds.left + w;
        bounds.top = 0;
        bounds.bottom = h;
        list.add(bounds);
    }
    return list;
}
Also used : Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) Paint(android.graphics.Paint)

Aggregations

Paint (android.graphics.Paint)3611 Canvas (android.graphics.Canvas)815 Bitmap (android.graphics.Bitmap)735 RectF (android.graphics.RectF)484 Rect (android.graphics.Rect)400 Path (android.graphics.Path)281 TextPaint (android.text.TextPaint)269 PorterDuffXfermode (android.graphics.PorterDuffXfermode)232 Matrix (android.graphics.Matrix)173 SuppressLint (android.annotation.SuppressLint)148 Point (android.graphics.Point)147 TypedArray (android.content.res.TypedArray)134 BitmapShader (android.graphics.BitmapShader)117 View (android.view.View)103 Drawable (android.graphics.drawable.Drawable)99 BitmapDrawable (android.graphics.drawable.BitmapDrawable)92 ColorMatrix (android.graphics.ColorMatrix)76 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)66 Resources (android.content.res.Resources)65 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)57