Search in sources :

Example 16 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project nmid-headline by miao1007.

the class ProgressBarCircular method drawSecondAnimation.

/**
     * Draw second animation of view
     *
     * @param canvas
     */
private void drawSecondAnimation(Canvas canvas) {
    if (arcO == limite)
        arcD += 6;
    if (arcD >= 290 || arcO > limite) {
        arcO += 6;
        arcD -= 6;
    }
    if (arcO > limite + 290) {
        limite = arcO;
        arcO = limite;
        arcD = 1;
    }
    rotateAngle += 4;
    canvas.rotate(rotateAngle, getWidth() / 2, getHeight() / 2);
    Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas temp = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setColor(backgroundColor);
    //		temp.drawARGB(0, 0, 0, 255);
    temp.drawArc(new RectF(0, 0, getWidth(), getHeight()), arcO, arcD, true, paint);
    Paint transparentPaint = new Paint();
    transparentPaint.setAntiAlias(true);
    transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
    transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    temp.drawCircle(getWidth() / 2, getHeight() / 2, (getWidth() / 2) - dpToPx(4, getResources()), transparentPaint);
    canvas.drawBitmap(bitmap, 0, 0, new Paint());
}
Also used : RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) PorterDuffXfermode(android.graphics.PorterDuffXfermode) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint)

Example 17 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project nmid-headline by miao1007.

the class ProgressBarCircular method drawFirstAnimation.

/**
     * Draw first animation of view
     *
     * @param canvas
     */
private void drawFirstAnimation(Canvas canvas) {
    if (radius1 < getWidth() / 2) {
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(makePressColor());
        radius1 = (radius1 >= getWidth() / 2) ? (float) getWidth() / 2 : radius1 + 1;
        canvas.drawCircle(getWidth() / 2, getHeight() / 2, radius1, paint);
    } else {
        Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas temp = new Canvas(bitmap);
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(makePressColor());
        temp.drawCircle(getWidth() / 2, getHeight() / 2, getHeight() / 2, paint);
        Paint transparentPaint = new Paint();
        transparentPaint.setAntiAlias(true);
        transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
        transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
        if (cont >= 50) {
            radius2 = (radius2 >= getWidth() / 2) ? (float) getWidth() / 2 : radius2 + 1;
        } else {
            radius2 = (radius2 >= getWidth() / 2 - dpToPx(4, getResources())) ? (float) getWidth() / 2 - dpToPx(4, getResources()) : radius2 + 1;
        }
        temp.drawCircle(getWidth() / 2, getHeight() / 2, radius2, transparentPaint);
        canvas.drawBitmap(bitmap, 0, 0, new Paint());
        if (radius2 >= getWidth() / 2 - dpToPx(4, getResources()))
            cont++;
        if (radius2 >= getWidth() / 2)
            firstAnimationOver = true;
    }
}
Also used : Bitmap(android.graphics.Bitmap) PorterDuffXfermode(android.graphics.PorterDuffXfermode) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint)

Example 18 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project MaterialIntroView by iammert.

the class MaterialIntroView method init.

private void init(Context context) {
    setWillNotDraw(false);
    setVisibility(INVISIBLE);
    /**
         * set default values
         */
    maskColor = Constants.DEFAULT_MASK_COLOR;
    delayMillis = Constants.DEFAULT_DELAY_MILLIS;
    fadeAnimationDuration = Constants.DEFAULT_FADE_DURATION;
    padding = Constants.DEFAULT_TARGET_PADDING;
    colorTextViewInfo = Constants.DEFAULT_COLOR_TEXTVIEW_INFO;
    focusType = Focus.ALL;
    focusGravity = FocusGravity.CENTER;
    shapeType = ShapeType.CIRCLE;
    isReady = false;
    isFadeAnimationEnabled = true;
    dismissOnTouch = false;
    isLayoutCompleted = false;
    isInfoEnabled = false;
    isDotViewEnabled = false;
    isPerformClick = false;
    isImageViewEnabled = true;
    isIdempotent = false;
    /**
         * initialize objects
         */
    handler = new Handler();
    preferencesManager = new PreferencesManager(context);
    eraser = new Paint();
    eraser.setColor(0xFFFFFFFF);
    eraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    eraser.setFlags(Paint.ANTI_ALIAS_FLAG);
    View layoutInfo = LayoutInflater.from(getContext()).inflate(R.layout.material_intro_card, null);
    infoView = layoutInfo.findViewById(R.id.info_layout);
    textViewInfo = (TextView) layoutInfo.findViewById(R.id.textview_info);
    textViewInfo.setTextColor(colorTextViewInfo);
    imageViewIcon = (ImageView) layoutInfo.findViewById(R.id.imageview_icon);
    dotView = LayoutInflater.from(getContext()).inflate(R.layout.dotview, null);
    dotView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            targetShape.reCalculateAll();
            if (targetShape != null && targetShape.getPoint().y != 0 && !isLayoutCompleted) {
                if (isInfoEnabled)
                    setInfoLayout();
                if (isDotViewEnabled)
                    setDotViewLayout();
                removeOnGlobalLayoutListener(MaterialIntroView.this, this);
            }
        }
    });
}
Also used : PorterDuffXfermode(android.graphics.PorterDuffXfermode) Handler(android.os.Handler) Paint(android.graphics.Paint) PreferencesManager(co.mobiwise.materialintro.prefs.PreferencesManager) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ViewTreeObserver(android.view.ViewTreeObserver)

Example 19 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project qksms by moezbhatti.

the class ImageUtils method getCircleBitmap.

public static Bitmap getCircleBitmap(Bitmap bitmap, int radius) {
    Bitmap sbmp;
    if (bitmap.getWidth() != radius || bitmap.getHeight() != radius) {
        float smallest = Math.min(bitmap.getWidth(), bitmap.getHeight());
        float factor = smallest / radius;
        sbmp = Bitmap.createScaledBitmap(bitmap, (int) (bitmap.getWidth() / factor), (int) (bitmap.getHeight() / factor), false);
    } else {
        sbmp = bitmap;
    }
    Bitmap output = Bitmap.createBitmap(radius, radius, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    final int color = 0xffa19774;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, radius, radius);
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    paint.setDither(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(Color.parseColor("#BAB399"));
    canvas.drawCircle(radius / 2, radius / 2, radius / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(sbmp, rect, rect, paint);
    return output;
}
Also used : Bitmap(android.graphics.Bitmap) Rect(android.graphics.Rect) PorterDuffXfermode(android.graphics.PorterDuffXfermode) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 20 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project MaterialDesignLibrary by navasmdc.

the class ProgressBarCircularIndeterminate method drawFirstAnimation.

/**
	 * Draw first animation of view
	 * @param canvas
	 */
private void drawFirstAnimation(Canvas canvas) {
    if (radius1 < getWidth() / 2) {
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(makePressColor());
        radius1 = (radius1 >= getWidth() / 2) ? (float) getWidth() / 2 : radius1 + 1;
        canvas.drawCircle(getWidth() / 2, getHeight() / 2, radius1, paint);
    } else {
        Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas temp = new Canvas(bitmap);
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(makePressColor());
        temp.drawCircle(getWidth() / 2, getHeight() / 2, getHeight() / 2, paint);
        Paint transparentPaint = new Paint();
        transparentPaint.setAntiAlias(true);
        transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
        transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
        if (cont >= 50) {
            radius2 = (radius2 >= getWidth() / 2) ? (float) getWidth() / 2 : radius2 + 1;
        } else {
            radius2 = (radius2 >= getWidth() / 2 - Utils.dpToPx(4, getResources())) ? (float) getWidth() / 2 - Utils.dpToPx(4, getResources()) : radius2 + 1;
        }
        temp.drawCircle(getWidth() / 2, getHeight() / 2, radius2, transparentPaint);
        canvas.drawBitmap(bitmap, 0, 0, new Paint());
        if (radius2 >= getWidth() / 2 - Utils.dpToPx(4, getResources()))
            cont++;
        if (radius2 >= getWidth() / 2)
            firstAnimationOver = true;
    }
}
Also used : Bitmap(android.graphics.Bitmap) PorterDuffXfermode(android.graphics.PorterDuffXfermode) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint)

Aggregations

PorterDuffXfermode (android.graphics.PorterDuffXfermode)148 Paint (android.graphics.Paint)124 Canvas (android.graphics.Canvas)101 Bitmap (android.graphics.Bitmap)90 Rect (android.graphics.Rect)64 RectF (android.graphics.RectF)49 SuppressLint (android.annotation.SuppressLint)9 LinearGradient (android.graphics.LinearGradient)9 Matrix (android.graphics.Matrix)9 TypedArray (android.content.res.TypedArray)8 Point (android.graphics.Point)6 IOException (java.io.IOException)6 BitmapDrawable (android.graphics.drawable.BitmapDrawable)5 ColorMatrix (android.graphics.ColorMatrix)4 Path (android.graphics.Path)4 Resources (android.content.res.Resources)3 Drawable (android.graphics.drawable.Drawable)3 ResourceHelper (com.klinker.android.launcher.api.ResourceHelper)3 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)3 RadialGradient (android.graphics.RadialGradient)2