use of android.graphics.Paint in project BGABadgeView-Android by bingoogolapple.
the class BGABadgeViewHelper method initDefaultAttrs.
private void initDefaultAttrs(Context context, BadgeGravity defaultBadgeGravity) {
mBadgeNumberRect = new Rect();
mBadgeRectF = new RectF();
mBadgeBgColor = Color.RED;
mBadgeTextColor = Color.WHITE;
mBadgeTextSize = BGABadgeViewUtil.sp2px(context, 10);
mBadgePaint = new Paint();
mBadgePaint.setAntiAlias(true);
mBadgePaint.setStyle(Paint.Style.FILL);
// 设置mBadgeText居中,保证mBadgeText长度为1时,文本也能居中
mBadgePaint.setTextAlign(Paint.Align.CENTER);
mBadgePadding = BGABadgeViewUtil.dp2px(context, 4);
mBadgeVerticalMargin = BGABadgeViewUtil.dp2px(context, 4);
mBadgeHorizontalMargin = BGABadgeViewUtil.dp2px(context, 4);
mBadgeGravity = defaultBadgeGravity;
mIsShowBadge = false;
mBadgeText = null;
mBitmap = null;
mIsDraging = false;
mDragable = false;
mBadgeBorderColor = Color.WHITE;
mDragExtra = BGABadgeViewUtil.dp2px(context, 4);
mBadgeDragExtraRectF = new RectF();
}
use of android.graphics.Paint in project Lazy by l123456789jy.
the class BitmapUtil method lumAndHueAndSaturation.
/**
* 亮度、色相、饱和度处理
*
* @param bitmap 原图
* @param lumValue 亮度值
* @param hueValue 色相值
* @param saturationValue 饱和度值
* @return 亮度、色相、饱和度处理后的图片
*/
public static Bitmap lumAndHueAndSaturation(Bitmap bitmap, int lumValue, int hueValue, int saturationValue) {
// 计算出符合要求的饱和度值
float newSaturationValue = saturationValue * 1.0F / 127;
// 计算出符合要求的亮度值
float newlumValue = lumValue * 1.0F / 127;
// 计算出符合要求的色相值
float newHueValue = (hueValue - 127) * 1.0F / 127 * 180;
// 创建一个颜色矩阵并设置其饱和度
ColorMatrix colorMatrix = new ColorMatrix();
// 设置饱和度值
colorMatrix.setSaturation(newSaturationValue);
// 设置亮度值
colorMatrix.setScale(newlumValue, newlumValue, newlumValue, 1);
// 控制让红色区在色轮上旋转的角度
colorMatrix.setRotate(0, newHueValue);
// 控制让绿红色区在色轮上旋转的角度
colorMatrix.setRotate(1, newHueValue);
// 控制让蓝色区在色轮上旋转的角度
colorMatrix.setRotate(2, newHueValue);
// 创建一个画笔并设置其颜色过滤器
Paint paint = new Paint();
paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
// 创建一个新的图片并创建画布
Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(newBitmap);
// 将原图使用给定的画笔画到画布上
canvas.drawBitmap(bitmap, 0, 0, paint);
return newBitmap;
}
use of android.graphics.Paint in project Lazy by l123456789jy.
the class BitmapUtil method combineImagesToSameSize.
/**
* 合并
* @param bgd 后景Bitmap
* @param fg 前景Bitmap
* @return 合成后Bitmap
*/
public static Bitmap combineImagesToSameSize(Bitmap bgd, Bitmap fg) {
Bitmap bmp;
int width = bgd.getWidth() < fg.getWidth() ? bgd.getWidth() : fg.getWidth();
int height = bgd.getHeight() < fg.getHeight() ? bgd.getHeight() : fg.getHeight();
if (fg.getWidth() != width && fg.getHeight() != height) {
fg = zoom(fg, width, height);
}
if (bgd.getWidth() != width && bgd.getHeight() != height) {
bgd = zoom(bgd, width, height);
}
bmp = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Paint paint = new Paint();
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_ATOP));
Canvas canvas = new Canvas(bmp);
canvas.drawBitmap(bgd, 0, 0, null);
canvas.drawBitmap(fg, 0, 0, paint);
return bmp;
}
use of android.graphics.Paint in project TwinklingRefreshLayout by lcodecorex.
the class GoogleDotView method init.
private void init() {
r = DensityUtil.dp2px(getContext(), 4);
mPath = new Paint();
mPath.setAntiAlias(true);
mPath.setColor(Color.rgb(114, 114, 114));
animator1 = ValueAnimator.ofFloat(1f, 1.2f, 1f, 0.8f);
animator1.setDuration(800);
animator1.setInterpolator(new DecelerateInterpolator());
animator1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
fraction1 = (float) animation.getAnimatedValue();
invalidate();
}
});
animator1.setRepeatCount(ValueAnimator.INFINITE);
animator1.setRepeatMode(ValueAnimator.REVERSE);
animator2 = ValueAnimator.ofFloat(1f, 0.8f, 1f, 1.2f);
animator2.setDuration(800);
animator2.setInterpolator(new DecelerateInterpolator());
animator2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
fraction2 = (float) animation.getAnimatedValue();
}
});
animator2.setRepeatCount(ValueAnimator.INFINITE);
animator2.setRepeatMode(ValueAnimator.REVERSE);
}
use of android.graphics.Paint in project TwinklingRefreshLayout by lcodecorex.
the class RoundProgressView method init.
private void init() {
mPath = new Paint();
mPantR = new Paint();
mPantR.setColor(Color.WHITE);
mPantR.setAntiAlias(true);
mPath.setAntiAlias(true);
mPath.setColor(Color.rgb(114, 114, 114));
va = ValueAnimator.ofInt(0, 360);
va.setDuration(720);
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
endAngle = (int) animation.getAnimatedValue();
postInvalidate();
}
});
va.setRepeatCount(ValueAnimator.INFINITE);
va.setInterpolator(new AccelerateDecelerateInterpolator());
}
Aggregations