Java Code Examples for android.graphics.Paint#setMaskFilter()
The following examples show how to use
android.graphics.Paint#setMaskFilter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KcaViewButtonService.java From kcanotify_h5-master with GNU General Public License v3.0 | 6 votes |
private void setFairyImage() { boolean glow_available = fairy_glow_on && getBooleanPreferences(getApplicationContext(), PREF_KCA_NOTI_QUEST_FAIRY_GLOW); Bitmap src = KcaUtils.getFairyImageFromStorage(getApplicationContext(), viewBitmapId, dbHelper); Bitmap alpha = src.extractAlpha(); Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin, src.getHeight() + margin, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bmp); if (glow_available) { Paint glow_paint = new Paint(); glow_paint.setColor(glowColor); glow_paint.setMaskFilter(new BlurMaskFilter(glowRadius, BlurMaskFilter.Blur.OUTER)); canvas.drawBitmap(alpha, halfMargin, halfMargin, glow_paint); } Paint color_paint = new Paint(); if (taiha_status) { color_paint.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.colorHeavyDmgStateWarn), PorterDuff.Mode.MULTIPLY)); } else if (glow_available) { color_paint.setColorFilter(new PorterDuffColorFilter(glowColor2, PorterDuff.Mode.MULTIPLY)); } canvas.drawBitmap(src, halfMargin, halfMargin, color_paint); viewbutton.setImageBitmap(bmp); }
Example 2
Source File: FloatParticle.java From kAndroid with Apache License 2.0 | 6 votes |
public FloatParticle(int width, int height) { mWidth = width; mHeight = height; mRandom = new Random(); startPoint = new Point((int) (mRandom.nextFloat() * mWidth), (int) (mRandom.nextFloat() * mHeight)); // 抗锯齿 mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setColor(Color.WHITE); // 防抖动 mPaint.setDither(true); mPaint.setStyle(Paint.Style.FILL); // 设置模糊效果 边缘模糊 mPaint.setMaskFilter(new BlurMaskFilter(BLUR_SIZE, BlurMaskFilter.Blur.SOLID)); mPath = new Path(); mPathMeasure = new PathMeasure(); startPoint.x = (int) (mRandom.nextFloat() * mWidth); startPoint.y = (int) (mRandom.nextFloat() * mHeight); }
Example 3
Source File: KcaViewButtonService.java From kcanotify with GNU General Public License v3.0 | 6 votes |
private void setFairyImage() { boolean glow_available = fairy_glow_on && getBooleanPreferences(getApplicationContext(), PREF_KCA_NOTI_QUEST_FAIRY_GLOW); Bitmap src = KcaUtils.getFairyImageFromStorage(getApplicationContext(), viewBitmapId, dbHelper); Bitmap alpha = src.extractAlpha(); Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin, src.getHeight() + margin, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bmp); if (glow_available) { Paint glow_paint = new Paint(); glow_paint.setColor(glowColor); glow_paint.setMaskFilter(new BlurMaskFilter(glowRadius, BlurMaskFilter.Blur.OUTER)); canvas.drawBitmap(alpha, halfMargin, halfMargin, glow_paint); } Paint color_paint = new Paint(); if (taiha_status) { color_paint.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.colorHeavyDmgStateWarn), PorterDuff.Mode.MULTIPLY)); } else if (glow_available) { color_paint.setColorFilter(new PorterDuffColorFilter(glowColor2, PorterDuff.Mode.MULTIPLY)); } canvas.drawBitmap(src, halfMargin, halfMargin, color_paint); viewbutton.setImageBitmap(bmp); }
Example 4
Source File: MyViewWithTransparentArea.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
public MyViewWithTransparentArea(Context context) { super(context); overlayDefault = BitmapFactory.decodeResource(getResources(),R.drawable.dwarf); overlayDefault = Bitmap.createScaledBitmap( overlayDefault, 800, 800, false); overlay = BitmapFactory.decodeResource(getResources(),R.drawable.dwarf).copy(Bitmap.Config.ARGB_8888, true); c2 = new Canvas(overlay); pTouch = new Paint(Paint.ANTI_ALIAS_FLAG); pTouch.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT)); pTouch.setColor(Color.TRANSPARENT); pTouch.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.NORMAL)); }
Example 5
Source File: ImageTools.java From android-tv-launcher with MIT License | 6 votes |
/** *图片阴影 * @param originalBitmap */ public static Drawable drawImageDropShadow(Bitmap originalBitmap, Context context) { BlurMaskFilter blurFilter = new BlurMaskFilter(3,BlurMaskFilter.Blur.NORMAL); Paint shadowPaint = new Paint(); shadowPaint.setAlpha(80); shadowPaint.setColor(context.getResources().getColor(R.color.black)); shadowPaint.setMaskFilter(blurFilter); int[] offsetXY = new int[2]; Bitmap shadowBitmap = originalBitmap.extractAlpha(shadowPaint, offsetXY); Bitmap shadowImage32 = shadowBitmap.copy(Bitmap.Config.ARGB_8888, true); if ( !shadowImage32.isPremultiplied() ) { shadowImage32.setPremultiplied( true ); } Canvas c = new Canvas(shadowImage32); c.drawBitmap(originalBitmap, offsetXY[0], offsetXY[1], null); return new BitmapDrawable(shadowImage32); }
Example 6
Source File: GuideLayout.java From NewbieGuide with Apache License 2.0 | 6 votes |
private void init() { mPaint = new Paint(); mPaint.setAntiAlias(true); PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR); mPaint.setXfermode(xfermode); //设置画笔遮罩滤镜,可以传入BlurMaskFilter或EmbossMaskFilter,前者为模糊遮罩滤镜而后者为浮雕遮罩滤镜 //这个方法已经被标注为过时的方法了,如果你的应用启用了硬件加速,你是看不到任何阴影效果的 mPaint.setMaskFilter(new BlurMaskFilter(10, BlurMaskFilter.Blur.INNER)); //关闭当前view的硬件加速 setLayerType(LAYER_TYPE_SOFTWARE, null); //ViewGroup默认设定为true,会使onDraw方法不执行,如果复写了onDraw(Canvas)方法,需要清除此标记 setWillNotDraw(false); touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); }
Example 7
Source File: BitmapUtils.java From Android-Next with Apache License 2.0 | 6 votes |
/** * 为指定图片增加阴影 * * @param map 图片 * @param radius 阴影的半径 * @return */ public static Bitmap drawShadow(Bitmap map, int radius) { if (map == null) return null; BlurMaskFilter blurFilter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER); Paint shadowPaint = new Paint(); shadowPaint.setMaskFilter(blurFilter); int[] offsetXY = new int[2]; Bitmap shadowImage = map.extractAlpha(shadowPaint, offsetXY); shadowImage = shadowImage.copy(Config.ARGB_8888, true); Canvas c = new Canvas(shadowImage); c.drawBitmap(map, -offsetXY[0], -offsetXY[1], null); return shadowImage; }
Example 8
Source File: IconUtil.java From paper-launcher with MIT License | 5 votes |
private static Bitmap addShadow(final Bitmap bm, final int dstHeight, final int dstWidth, int color, int size, float dx, float dy) { final Bitmap mask = Bitmap.createBitmap(dstWidth, dstHeight, Bitmap.Config.ALPHA_8); final Matrix scaleToFit = new Matrix(); final RectF src = new RectF(0, 0, bm.getWidth(), bm.getHeight()); final RectF dst = new RectF(0, 0, dstWidth - dx, dstHeight - dy); scaleToFit.setRectToRect(src, dst, Matrix.ScaleToFit.CENTER); final Matrix dropShadow = new Matrix(scaleToFit); dropShadow.postTranslate(dx, dy); final Canvas maskCanvas = new Canvas(mask); final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); maskCanvas.drawBitmap(bm, scaleToFit, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT)); maskCanvas.drawBitmap(bm, dropShadow, paint); final BlurMaskFilter filter = new BlurMaskFilter(size, BlurMaskFilter.Blur.NORMAL); paint.reset(); paint.setAntiAlias(true); paint.setColor(color); paint.setMaskFilter(filter); paint.setFilterBitmap(true); final Bitmap ret = Bitmap.createBitmap(dstWidth, dstHeight, Bitmap.Config.ARGB_8888); final Canvas retCanvas = new Canvas(ret); retCanvas.drawBitmap(mask, 0, 0, paint); retCanvas.drawBitmap(bm, scaleToFit, null); mask.recycle(); return ret; }
Example 9
Source File: LauncherIconHelper.java From HgLauncher with GNU General Public License v3.0 | 5 votes |
/** * Adds a shadow to a Bitmap. * <p> * TODO: Make this return Drawable for our use case. * * @param drawable Drawable that should be used as the foreground layer * of the shadow. * @param dstHeight Height of the returned bitmap. * @param dstWidth Width of the returned bitmap. * @param color Colour of the drawn shadow. * @param size Size of the drawn shadow. * @param dx Shadow x direction. * @param dy Shadow y direction. * * @return Bitmap with resulting shadow. * * @author schwiz (https://stackoverflow.com/a/24579764) */ private static Bitmap addShadow(final Drawable drawable, final int dstHeight, final int dstWidth, int color, int size, float dx, float dy) { final Bitmap bm = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bm); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); final Bitmap mask = Bitmap.createBitmap(dstWidth, dstHeight, Bitmap.Config.ALPHA_8); final Matrix scaleToFit = new Matrix(); final RectF src = new RectF(0, 0, bm.getWidth(), bm.getHeight()); final RectF dst = new RectF(0, 0, dstWidth - dx, dstHeight - dy); scaleToFit.setRectToRect(src, dst, Matrix.ScaleToFit.FILL); final Matrix dropShadow = new Matrix(scaleToFit); dropShadow.postTranslate(dx, dy); final Canvas maskCanvas = new Canvas(mask); final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); maskCanvas.drawBitmap(bm, scaleToFit, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT)); maskCanvas.drawBitmap(bm, dropShadow, paint); final BlurMaskFilter filter = new BlurMaskFilter(size, BlurMaskFilter.Blur.SOLID); paint.reset(); paint.setAntiAlias(true); paint.setColor(color); paint.setMaskFilter(filter); paint.setFilterBitmap(true); final Bitmap ret = Bitmap.createBitmap(dstWidth, dstHeight, Bitmap.Config.ARGB_8888); final Canvas retCanvas = new Canvas(ret); retCanvas.drawBitmap(mask, 0, 0, paint); retCanvas.drawBitmap(bm, scaleToFit, null); mask.recycle(); return ret; }
Example 10
Source File: ScheduleClassAdapter.java From utexas-utilities with Apache License 2.0 | 5 votes |
private void drawCurrentMinutesLine(Shape shape, Canvas canvas, Paint paint, int bgColor) { paint.setStrokeWidth(3f); paint.setColor(Color.BLACK); paint.setStyle(Paint.Style.STROKE); canvas.drawColor(bgColor); Paint blur = new Paint(paint); blur.setStrokeWidth(3f); blur.setMaskFilter(new BlurMaskFilter(3, BlurMaskFilter.Blur.SOLID)); canvas.drawLine(0, (int) ((currMinutes / 30.0) * shape.getHeight() + .5), shape.getWidth(), (int) ((currMinutes / 30.0) * shape.getHeight() + .5), paint); }
Example 11
Source File: RichPolyline.java From richmaps with Apache License 2.0 | 5 votes |
protected Paint getDefaultStrokePaint() { Paint paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setColor(strokeColor); paint.setStrokeWidth(strokeWidth); paint.setAntiAlias(antialias); paint.setStrokeCap(strokeCap); paint.setStrokeJoin(strokeJoin); paint.setPathEffect(pathEffect); paint.setMaskFilter(maskFilter); return paint; }
Example 12
Source File: ShaderImageView.java From support with Apache License 2.0 | 5 votes |
private Bitmap drawBitmap(Bitmap original) { Bitmap bitmap = Bitmap.createBitmap(original.getWidth(), original.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setColorFilter(new ColorMatrixColorFilter( getColorMatrix())); paint.setMaskFilter(new BlurMaskFilter(200, BlurMaskFilter.Blur.NORMAL)); canvas.drawBitmap(original, 0, 0, paint); return bitmap; }
Example 13
Source File: ShadowGenerator.java From LaunchEnr with GNU General Public License v3.0 | 5 votes |
private ShadowGenerator(Context context) { mIconSize = LauncherAppState.getIDP(context).iconBitmapSize; mCanvas = new Canvas(); mBlurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); mBlurPaint.setMaskFilter(new BlurMaskFilter(mIconSize * BLUR_FACTOR, Blur.NORMAL)); mDrawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); }
Example 14
Source File: CircleLightShape.java From Highlight with Apache License 2.0 | 5 votes |
@Override protected void drawShape(Bitmap bitmap, HighLight.ViewPosInfo viewPosInfo) { Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setDither(true); paint.setAntiAlias(true); if (blurRadius > 0) { paint.setMaskFilter(new BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.SOLID)); } RectF rectF = viewPosInfo.rectF; canvas.drawCircle(rectF.left+(rectF.width()/2),rectF.top+(rectF.height()/2), Math.max(rectF.width(),rectF.height())/2,paint); }
Example 15
Source File: ColorizeFaceActivity.java From FaceT with Mozilla Public License 2.0 | 4 votes |
private void lipLayer() { Canvas drawCanvas = new Canvas(temp); Paint mPaint = new Paint(); mPaint.setXfermode(mXfermode); int rougeLayer = 0xEEFAFAFA; mPaint.setColor(rougeLayer); mPaint.setStyle(Paint.Style.FILL); mPaint.setStrokeJoin(Paint.Join.ROUND); // set the join to round you want mPaint.setStrokeCap(Paint.Cap.ROUND); // set the paint cap to round too mPaint.setPathEffect(new CornerPathEffect(50)); mPaint.setStrokeWidth(1f); int sc = drawCanvas.saveLayer(0, 0, temp.getWidth(), temp.getHeight(), null, Canvas.ALL_SAVE_FLAG); mPaint.setMaskFilter(new BlurMaskFilter(60f, BlurMaskFilter.Blur.OUTER)); Path path = new Path(); path.reset(); path.moveTo(landmark_pt_x.get(48), landmark_pt_y.get(48)); for (int i = 49; i < 55; i++) path.lineTo(landmark_pt_x.get(i), landmark_pt_y.get(i) + 2f); path.lineTo(landmark_pt_x.get(64), landmark_pt_y.get(64) - 2f); path.lineTo(landmark_pt_x.get(63), landmark_pt_y.get(63) - 2f); path.lineTo(landmark_pt_x.get(62), landmark_pt_y.get(62) - 2f); path.lineTo(landmark_pt_x.get(60), landmark_pt_y.get(60) - 2f); path.lineTo(landmark_pt_x.get(48), landmark_pt_y.get(48) - 2f); path.close(); drawCanvas.drawPath(path, mPaint); path.reset(); path.moveTo(landmark_pt_x.get(48), landmark_pt_y.get(48)); path.lineTo(landmark_pt_x.get(59), landmark_pt_y.get(59) + 2f); path.lineTo(landmark_pt_x.get(58), landmark_pt_y.get(58) + 2f); path.lineTo(landmark_pt_x.get(57), landmark_pt_y.get(57) + 2f); path.lineTo(landmark_pt_x.get(56), landmark_pt_y.get(56) + 2f); path.lineTo(landmark_pt_x.get(55), landmark_pt_y.get(55) + 2f); path.lineTo(landmark_pt_x.get(54), landmark_pt_y.get(54) + 2f); for (int i = 64; i < 68; i++) path.lineTo(landmark_pt_x.get(i), landmark_pt_y.get(i) - 2f); path.lineTo(landmark_pt_x.get(60), landmark_pt_y.get(60) - 2f); path.lineTo(landmark_pt_x.get(48), landmark_pt_y.get(48) - 2f); path.close(); drawCanvas.drawPath(path, mPaint); }
Example 16
Source File: SingleMakeupActivity.java From FaceT with Mozilla Public License 2.0 | 4 votes |
private void drawRouge(String blushColor, Bitmap getBitmap) { Canvas drawCanvas = new Canvas(getBitmap); Paint mPaint = new Paint(); int rougeColor = stringColorRGBToARGB(blushColor, 35 + alphaValueRouge, 0, 0, 0); mPaint.setColor(rougeColor); mPaint.setStyle(Paint.Style.FILL); mPaint.setStrokeJoin(Paint.Join.ROUND); // set the join to round you want mPaint.setStrokeCap(Paint.Cap.ROUND); // set the paint cap to round too mPaint.setPathEffect(new CornerPathEffect(70)); mPaint.setXfermode(mXfermode); mPaint.setStrokeWidth(1f); int sc = drawCanvas.saveLayer(0, 0, getBitmap.getWidth(), getBitmap.getHeight(), null, Canvas.ALL_SAVE_FLAG); mPaint.setMaskFilter(new BlurMaskFilter(10, BlurMaskFilter.Blur.NORMAL)); //nose_contour_left2 - contour_left3 float rouge_left_x = landmark_pt_x.get(30) - (landmark_pt_x.get(30) - landmark_pt_x.get(2)) / 2f; float rouge_left_y = landmark_pt_y.get(31); float slope = ((landmark_pt_y.get(31) - landmark_pt_y.get(35)) / (landmark_pt_x.get(31) - landmark_pt_x.get(35))); rouge_left_y = ((rouge_left_x - landmark_pt_x.get(31)) * slope) + landmark_pt_y.get(31); // drawCanvas.drawCircle(rouge_left_x, rouge_left_y, 30f, mPaint); // nose_contour_right2 - contour_right3 float rouge_right_x = landmark_pt_x.get(30) + (landmark_pt_x.get(14) - landmark_pt_x.get(30)) / 2f; float rouge_right_y = landmark_pt_y.get(35); rouge_right_y = ((rouge_right_x - landmark_pt_x.get(35)) * slope) + landmark_pt_y.get(35); Path path = new Path(); path.reset(); //draw left rouge // contour_left3 path.moveTo(landmark_pt_x.get(2) + 3f, landmark_pt_y.get(2)); path.cubicTo(landmark_pt_x.get(3) + 3f, landmark_pt_y.get(3), landmark_pt_x.get(4) + 3f, landmark_pt_y.get(4), landmark_pt_x.get(5) + 3f, landmark_pt_y.get(5) - 4f ); path.lineTo(rouge_left_x, rouge_left_y); path.lineTo(landmark_pt_x.get(2) + 3f, landmark_pt_y.get(2)); path.close(); drawCanvas.drawPath(path, mPaint); path.reset(); //draw right rouge // contour_right3 path.moveTo(landmark_pt_x.get(14) - 3f, landmark_pt_y.get(14)); path.cubicTo(landmark_pt_x.get(13) - 3f, landmark_pt_y.get(13), landmark_pt_x.get(12) - 3f, landmark_pt_y.get(12), landmark_pt_x.get(11) - 3f, landmark_pt_y.get(11) - 4f ); path.lineTo(rouge_right_x, rouge_right_y); path.lineTo(landmark_pt_x.get(14) - 3f, landmark_pt_y.get(14)); drawCanvas.drawPath(path, mPaint); //设置混合模式 mPaint.setXfermode(mXfermode); //清除混合模式 mPaint.setXfermode(null); //还原画布 drawCanvas.restoreToCount(sc); drawCanvas.setBitmap(getBitmap); }
Example 17
Source File: CircularSeekBar.java From CircularSeekBar with Apache License 2.0 | 4 votes |
/** * Initializes the {@code Paint} objects with the appropriate styles. */ private void initPaints() { mCirclePaint = new Paint(); mCirclePaint.setAntiAlias(true); mCirclePaint.setDither(true); mCirclePaint.setColor(mCircleColor); mCirclePaint.setStrokeWidth(mCircleStrokeWidth); mCirclePaint.setStyle(Paint.Style.STROKE); mCirclePaint.setStrokeJoin(Paint.Join.ROUND); mCirclePaint.setStrokeCap(mCircleStyle); mCircleFillPaint = new Paint(); mCircleFillPaint.setAntiAlias(true); mCircleFillPaint.setDither(true); mCircleFillPaint.setColor(mCircleFillColor); mCircleFillPaint.setStyle(Paint.Style.FILL); mCircleProgressPaint = new Paint(); mCircleProgressPaint.setAntiAlias(true); mCircleProgressPaint.setDither(true); mCircleProgressPaint.setColor(mCircleProgressColor); mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth); mCircleProgressPaint.setStyle(Paint.Style.STROKE); mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND); mCircleProgressPaint.setStrokeCap(mCircleStyle); if (!mDisableProgressGlow) { mCircleProgressGlowPaint = new Paint(); mCircleProgressGlowPaint.set(mCircleProgressPaint); mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((PROGRESS_GLOW_RADIUS_DP * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL)); } mPointerPaint = new Paint(); mPointerPaint.setAntiAlias(true); mPointerPaint.setDither(true); mPointerPaint.setColor(mPointerColor); mPointerPaint.setStrokeWidth(mPointerStrokeWidth); mPointerPaint.setStyle(Paint.Style.STROKE); mPointerPaint.setStrokeJoin(Paint.Join.ROUND); mPointerPaint.setStrokeCap(mCircleStyle); mPointerHaloPaint = new Paint(); mPointerHaloPaint.set(mPointerPaint); mPointerHaloPaint.setColor(mPointerHaloColor); mPointerHaloPaint.setAlpha(mPointerAlpha); mPointerHaloPaint.setStrokeWidth(mPointerStrokeWidth + mPointerHaloWidth * 2f); mPointerHaloBorderPaint = new Paint(); mPointerHaloBorderPaint.set(mPointerPaint); mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth); mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE); }
Example 18
Source File: YummyTextSwitcher.java From YummyTextSwitcher with MIT License | 4 votes |
private void init() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { //View从API Level 11才加入setLayerType方法 //设置myView以软件渲染模式绘图 setLayerType(View.LAYER_TYPE_SOFTWARE, null); } mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTextPaint.setTextSize(mTextSize); mTextPaint.setAntiAlias(true); mTextPaint.setTextSize(mTextSize); mTextPaint.setColor(mTextColor); mTextPaint.setStyle(Paint.Style.FILL); mTextPaint.setTextAlign(Paint.Align.CENTER); mFirstFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mFirstFramePaint.setTextSize(mTextSize); mFirstFramePaint.setAntiAlias(true); mFirstFramePaint.setTextSize(mTextSize); mFirstFramePaint.setColor(mTextColor); mFirstFramePaint.setStyle(Paint.Style.FILL); mFirstFramePaint.setTextAlign(Paint.Align.CENTER); mSecondFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mSecondFramePaint.setTextSize(mTextSize); mSecondFramePaint.setAntiAlias(true); mSecondFramePaint.setTextSize(mTextSize); mSecondFramePaint.setColor(mTextColor); mSecondFramePaint.setStyle(Paint.Style.FILL); mSecondFramePaint.setTextAlign(Paint.Align.CENTER); mMiddleFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mMiddleFramePaint.setTextSize(mTextSize); mMiddleFramePaint.setAntiAlias(true); mMiddleFramePaint.setTextSize(mTextSize); mMiddleFramePaint.setColor(mTextColor); mMiddleFramePaint.setStyle(Paint.Style.FILL); mMiddleFramePaint.setTextAlign(Paint.Align.CENTER); mMaskFilterFirst = new BlurMaskFilter(3, BlurMaskFilter.Blur.NORMAL); mMaskFilterSecond = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL); mMaskFilterMiddle = new BlurMaskFilter(18, BlurMaskFilter.Blur.NORMAL); mFirstFramePaint.setMaskFilter(mMaskFilterFirst); mSecondFramePaint.setMaskFilter(mMaskFilterSecond); mMiddleFramePaint.setMaskFilter(mMaskFilterMiddle); testPaint = new Paint(); testPaint.setStyle(Paint.Style.FILL); testPaint.setColor(Color.WHITE); if (mFrameOffset <= 0) { Paint.FontMetricsInt fmi = mTextPaint.getFontMetricsInt(); mFrameOffset = fmi.bottom - fmi.top; } }
Example 19
Source File: CircularSeekBar.java From circularseekbar with Apache License 2.0 | 4 votes |
/** * Initializes the {@code Paint} objects with the appropriate styles. */ protected void initPaints() { mCirclePaint = new Paint(); mCirclePaint.setAntiAlias(true); mCirclePaint.setDither(true); mCirclePaint.setColor(mCircleColor); mCirclePaint.setStrokeWidth(mCircleStrokeWidth); mCirclePaint.setStyle(Paint.Style.STROKE); mCirclePaint.setStrokeJoin(Paint.Join.ROUND); mCirclePaint.setStrokeCap(Paint.Cap.ROUND); mCircleFillPaint = new Paint(); mCircleFillPaint.setAntiAlias(true); mCircleFillPaint.setDither(true); mCircleFillPaint.setColor(mCircleFillColor); mCircleFillPaint.setStyle(Paint.Style.FILL); mCircleProgressPaint = new Paint(); mCircleProgressPaint.setAntiAlias(true); mCircleProgressPaint.setDither(true); mCircleProgressPaint.setColor(mCircleProgressColor); mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth); mCircleProgressPaint.setStyle(Paint.Style.STROKE); mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND); mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND); mCircleProgressGlowPaint = new Paint(); mCircleProgressGlowPaint.set(mCircleProgressPaint); mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL)); mPointerPaint = new Paint(); mPointerPaint.setAntiAlias(true); mPointerPaint.setDither(true); mPointerPaint.setStyle(Paint.Style.FILL); mPointerPaint.setColor(mPointerColor); mPointerPaint.setStrokeWidth(mPointerRadius); mPointerHaloPaint = new Paint(); mPointerHaloPaint.set(mPointerPaint); mPointerHaloPaint.setColor(mPointerHaloColor); mPointerHaloPaint.setAlpha(mPointerAlpha); mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth); mPointerHaloBorderPaint = new Paint(); mPointerHaloBorderPaint.set(mPointerPaint); mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth); mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE); }
Example 20
Source File: EasyGuideView.java From EasyGuideView with Apache License 2.0 | 4 votes |
private void initPaint() { mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setColor(mBgColor); mPaint.setMaskFilter(new BlurMaskFilter(10, BlurMaskFilter.Blur.INNER)); }