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());
}
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;
}
}
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);
}
}
});
}
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;
}
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;
}
}
Aggregations