private void initAnimation() { paint.setStrokeWidth(getHeight() * 0.01f); paint.setAntiAlias(true); paint.setDither(true); paint.setColor(Color.argb(248, 255, 255, 255)); paint.setStrokeWidth(20f); paint.setStyle(Paint.Style.STROKE); paint.setStrokeJoin(Paint.Join.ROUND); paint.setStrokeCap(Paint.Cap.ROUND); paintGlow.set(paint); paintGlow.setColor(Color.argb(235, 74, 138, 255)); paintGlow.setStrokeWidth(30f); paintGlow.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.NORMAL)); float deltaY = (CameraOverlayView.PADDING * 2) * getHeight(); Log.i(TAG, String.format("Delta Y : %s", deltaY)); TranslateAnimation mAnimation = new TranslateAnimation(0f, 0f, 0f, deltaY); mAnimation.setDuration(3000); mAnimation.setRepeatCount(-1); mAnimation.setRepeatMode(Animation.REVERSE); mAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); setAnimation(mAnimation); }
public void init() { mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBackgroundPaint.setStyle(Paint.Style.FILL_AND_STROKE); mBackgroundPaint.setColor(mBackgroudColor); mFocusPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mFocusPaint.setStyle(Paint.Style.FILL_AND_STROKE); mFocusPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); if (mBlurRadius > 0) mFocusPaint.setMaskFilter(new BlurMaskFilter(mBlurRadius, BlurMaskFilter.Blur.NORMAL)); setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (mTipsView == null && mTipsViewResId != 0) mTipsView = LayoutInflater.from(mContext).inflate(mTipsViewResId, this, false); addView(mTipsView); setVisibility(View.GONE); setBackgroundColor(Color.TRANSPARENT); mTargetView.getViewTreeObserver().addOnGlobalLayoutListener(this); }
/** *图片阴影 * @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); }
RenderThread(Context context, SurfaceHolder mSurfaceHolder) { this.mSurfaceHolder = mSurfaceHolder; SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); mUniverse = new UniverseBuilder() .setPreferences(preferences) .setHeight(displayMetrics.heightPixels) .setWidth(displayMetrics.widthPixels) .create(); mPaint = new Paint(); mPaint.setAntiAlias(true); mPath = new Path(); mBlurFilter = new BlurMaskFilter(mUniverse.getStarGlowSize(), BlurMaskFilter.Blur.SOLID); }
public void setPaintMaskFilter(int mode) { switch (mode) { case UsoppBubble.MODE_NONE: break; case UsoppBubble.MODE_GLOW: mDataBean.mFilter = new BlurMaskFilter(10, BlurMaskFilter.Blur.OUTER); break; case UsoppBubble.MODE_EMBOSS: float[] direction = new float[]{10, 10, 10}; float ambient = 0.5f; float specular = 1; float blurRadius = 1; mDataBean.mFilter = new EmbossMaskFilter(direction, ambient, specular, blurRadius); break; } mDataBean.mPaint.setMaskFilter(mDataBean.mFilter); }
/** * 为指定图片增加阴影 * * @param map 图片 * @param radius 阴影的半径 * @return bitmap */ 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(Bitmap.Config.ARGB_8888, true); Canvas c = new Canvas(shadowImage); c.drawBitmap(map, -offsetXY[0], -offsetXY[1], null); return shadowImage; }
@Override protected synchronized void onSizeChanged(int width, int height, int old_width, int old_height) { super.onSizeChanged(width, height, old_width, old_height); if ((width == 0) || (height == 0)) return; // paddingを考慮してマスク用のDrawableのサイズを計算 final int padding_left = getPaddingLeft(); final int padding_top = getPaddingTop(); final int sz = Math.min(width - padding_left - getPaddingRight(), height - padding_top - getPaddingBottom()); final int left = (width - sz) / 2 + padding_left; final int top = (height - sz) / 2 + padding_top; mMaskBounds.set(left, top, left + sz, top + sz); if (sz > 3) { mMaskedPaint.setMaskFilter(new BlurMaskFilter(sz * 2 / 3.0f, BlurMaskFilter.Blur.NORMAL)); } // View自体のサイズはそのまま mViewBoundsF.set(0, 0, width, height); if (mMaskDrawable != null) { mMaskDrawable.setBounds(mMaskBounds); } }
public Bitmap doHighlightImage(Bitmap originalImage, int radius, @ColorInt int highlightColor) { Bitmap resultingBitmap = Bitmap.createBitmap(originalImage.getWidth() + 96, originalImage.getHeight() + 96, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(resultingBitmap); canvas.drawColor(0, PorterDuff.Mode.CLEAR); Paint paintBlur = new Paint(); paintBlur.setMaskFilter(new BlurMaskFilter(radius, BlurMaskFilter.Blur.NORMAL)); int[] offsetXY = new int[2]; Bitmap bitmapAlpha = originalImage.extractAlpha(paintBlur, offsetXY); Paint paintAlphaColor = new Paint(); paintAlphaColor.setColor(highlightColor); canvas.drawBitmap(bitmapAlpha, offsetXY[0], offsetXY[1], paintAlphaColor); bitmapAlpha.recycle(); canvas.drawBitmap(originalImage, 0, 0, null); return resultingBitmap; }
private HolographicOutlineHelper(Context context) { Resources res = context.getResources(); float mediumBlur = res.getDimension(R.dimen.blur_size_medium_outline); mMediumOuterBlurMaskFilter = new BlurMaskFilter(mediumBlur, BlurMaskFilter.Blur.OUTER); mMediumInnerBlurMaskFilter = new BlurMaskFilter(mediumBlur, BlurMaskFilter.Blur.NORMAL); mThinOuterBlurMaskFilter = new BlurMaskFilter( res.getDimension(R.dimen.blur_size_thin_outline), BlurMaskFilter.Blur.OUTER); mShadowBlurMaskFilter = new BlurMaskFilter( res.getDimension(R.dimen.blur_size_click_shadow), BlurMaskFilter.Blur.NORMAL); mDrawPaint.setFilterBitmap(true); mDrawPaint.setAntiAlias(true); mBlurPaint.setFilterBitmap(true); mBlurPaint.setAntiAlias(true); mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); mErasePaint.setFilterBitmap(true); mErasePaint.setAntiAlias(true); }
/** * 可以对该图的非透明区域着色 * <p> * 有多种使用场景,常见如 Button 的 pressed 状态,View 的阴影状态等 * * @param iv * @param src * @param radius * @param color * @return */ private static Bitmap getDropShadow(ImageView iv, Bitmap src, float radius, int color) { final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(color); final int width = src.getWidth(), height = src.getHeight(); final Bitmap dest = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(dest); final Bitmap alpha = src.extractAlpha(); canvas.drawBitmap(alpha, 0, 0, paint); final BlurMaskFilter filter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER); paint.setMaskFilter(filter); canvas.drawBitmap(alpha, 0, 0, paint); iv.setImageBitmap(dest); return dest; }
public GuideDrawable(float x, float y, float w, float h) { float density = getResources().getDisplayMetrics().density; mClipPath = new Path(); mClipPath.addRect(x, y, x + w, y + h, Path.Direction.CW); mBorderPath = new Path(); mBorderPath.addRect(x - density, y - density, x + w + density, y + h + density, Path.Direction.CW); mShadowPath = new Path(); mShadowPath.addRect(x - 3 * density, y - 3 * density, x + w + 3 * density, y + h + 3 * density, Path.Direction.CW); mScale = new RectF(x + w / 2, y + h / 2, 1 + 8 * density / w, 1 + 8 * density / h); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setColor(getResources().getColor(R.color.state_button_light)); mPaint2 = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint2.setColor(getResources().getColor(R.color.state_button_light_alpha)); mPaint2.setMaskFilter(new BlurMaskFilter(density * 3, BlurMaskFilter.Blur.NORMAL)); }
public GuideDrawable(float cX, float cY, float radius) { float density = getResources().getDisplayMetrics().density; mClipPath = new Path(); mClipPath.addCircle(cX, cY, radius, Path.Direction.CW); mBorderPath = new Path(); mBorderPath.addCircle(cX, cY, radius + 2 * density, Path.Direction.CW); mShadowPath = new Path(); mShadowPath.addCircle(cX, cY, radius + 4 * density, Path.Direction.CW); mScale = new RectF(cX, cY, 1 + 8 * density / radius, 1 + 8 * density / radius); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setColor(getResources().getColor(R.color.state_button_light)); mPaint2 = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint2.setColor(getResources().getColor(R.color.state_button_light_alpha)); mPaint2.setMaskFilter(new BlurMaskFilter(density * 5, BlurMaskFilter.Blur.NORMAL)); }
private void setFairyImage() { boolean glow_available = fairy_glow_on && getBooleanPreferences(getApplicationContext(), PREF_KCA_NOTI_QUEST_FAIRY_GLOW); Bitmap src = BitmapFactory.decodeResource(getResources(), viewBitmapId); 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); }
public void setWithEffects(boolean withEffects) { this.withEffects = withEffects; if (isInEditMode()) return; indicatorEffects(withEffects); if (withEffects) { rayPaint.setMaskFilter(new BlurMaskFilter(3, BlurMaskFilter.Blur.SOLID)); activeMarkPaint.setMaskFilter(new BlurMaskFilter(5, BlurMaskFilter.Blur.SOLID)); speedBackgroundPaint.setMaskFilter(new BlurMaskFilter(8, BlurMaskFilter.Blur.SOLID)); } else { rayPaint.setMaskFilter(null); activeMarkPaint.setMaskFilter(null); speedBackgroundPaint.setMaskFilter(null); } updateBackgroundBitmap(); invalidate(); }
public void setWithEffects(boolean withEffects) { this.withEffects = withEffects; if (isInEditMode()) return; indicatorEffects(withEffects); if (withEffects) { markPaint.setMaskFilter(new BlurMaskFilter(5, BlurMaskFilter.Blur.SOLID)); speedBackgroundPaint.setMaskFilter(new BlurMaskFilter(8, BlurMaskFilter.Blur.SOLID)); circlePaint.setMaskFilter(new BlurMaskFilter(10, BlurMaskFilter.Blur.SOLID)); } else { markPaint.setMaskFilter(null); speedBackgroundPaint.setMaskFilter(null); circlePaint.setMaskFilter(null); } updateBackgroundBitmap(); invalidate(); }
private static void initStatics(Context context) { final Resources resources = context.getResources(); final DisplayMetrics metrics = resources.getDisplayMetrics(); final float density = metrics.density; sIconWidth = sIconHeight = (int) resources.getDimension(android.R.dimen.app_icon_size); sIconTextureWidth = sIconTextureHeight = sIconWidth; sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL)); sGlowColorPressedPaint.setColor(0xffffc300); sGlowColorFocusedPaint.setColor(0xffff8e00); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0.2f); sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm)); sDisabledPaint.setAlpha(0x88); }
/** * Instantiates a new ab horizontal progress bar. * * @param context the context * @param attrs the attrs */ public AbHorizontalProgressBar(Context context, AttributeSet attrs) { super(context, attrs); pathPaint = new Paint(); // 设置是否抗锯齿 pathPaint.setAntiAlias(true); // 帮助消除锯齿 pathPaint.setFlags(Paint.ANTI_ALIAS_FLAG); // 设置中空的样式 pathPaint.setStyle(Paint.Style.FILL); pathPaint.setDither(true); //pathPaint.setStrokeJoin(Paint.Join.ROUND); fillPaint = new Paint(); // 设置是否抗锯齿 fillPaint.setAntiAlias(true); // 帮助消除锯齿 fillPaint.setFlags(Paint.ANTI_ALIAS_FLAG); // 设置中空的样式 fillPaint.setStyle(Paint.Style.FILL); fillPaint.setDither(true); //fillPaint.setStrokeJoin(Paint.Join.ROUND); emboss = new EmbossMaskFilter(direction,light,specular,blur); mBlur = new BlurMaskFilter(20, BlurMaskFilter.Blur.NORMAL); }
public void setMaskFilter(MenuItem item) { switch (item.getItemId()) { case R.id.action_solid: mShadowPaint.setMaskFilter(new BlurMaskFilter(10, BlurMaskFilter.Blur.SOLID)); break; case R.id.action_normal: mShadowPaint.setMaskFilter(new BlurMaskFilter(10, BlurMaskFilter.Blur.NORMAL)); break; case R.id.action_outer: mShadowPaint.setMaskFilter(new BlurMaskFilter(10, BlurMaskFilter.Blur.OUTER)); break; case R.id.action_inner: mShadowPaint.setMaskFilter(new BlurMaskFilter(10, BlurMaskFilter.Blur.INNER)); break; } invalidate(); }
private HolographicOutlineHelper(Context context) { final float scale = LauncherAppState.getInstance().getScreenDensity(); mMinOuterBlurRadius = (int) (scale * 1.0f); mMaxOuterBlurRadius = (int) (scale * 12.0f); mExtraThickOuterBlurMaskFilter = new BlurMaskFilter(scale * 12.0f, BlurMaskFilter.Blur.OUTER); mThickOuterBlurMaskFilter = new BlurMaskFilter(scale * 6.0f, BlurMaskFilter.Blur.OUTER); mMediumOuterBlurMaskFilter = new BlurMaskFilter(scale * 2.0f, BlurMaskFilter.Blur.OUTER); mThinOuterBlurMaskFilter = new BlurMaskFilter(scale * 1.0f, BlurMaskFilter.Blur.OUTER); mExtraThickInnerBlurMaskFilter = new BlurMaskFilter(scale * 6.0f, BlurMaskFilter.Blur.NORMAL); mThickInnerBlurMaskFilter = new BlurMaskFilter(scale * 4.0f, BlurMaskFilter.Blur.NORMAL); mMediumInnerBlurMaskFilter = new BlurMaskFilter(scale * 2.0f, BlurMaskFilter.Blur.NORMAL); mHolographicPaint.setFilterBitmap(true); mHolographicPaint.setAntiAlias(true); mBlurPaint.setFilterBitmap(true); mBlurPaint.setAntiAlias(true); mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); mErasePaint.setFilterBitmap(true); mErasePaint.setAntiAlias(true); }
private static void initStatics(Context context) { final Resources resources = context.getResources(); final DisplayMetrics metrics = resources.getDisplayMetrics(); final float density = metrics.density; sIconWidth = sIconHeight = (int) resources.getDimension(R.dimen.app_icon_size); sIconTextureWidth = sIconTextureHeight = sIconWidth; sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL)); sGlowColorPressedPaint.setColor(0xffffc300); sGlowColorFocusedPaint.setColor(0xffff8e00); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0.2f); sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm)); sDisabledPaint.setAlpha(0x88); }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); int width = canvas.getWidth(); float height = canvas.getHeight(); int maxValueStepsCount = mMaxValue - mMinValue + 1; mValueStep = (height / maxValueStepsCount); mRadialPaint.setMaskFilter(new BlurMaskFilter(20, BlurMaskFilter.Blur.NORMAL)); updatePaintColorByValue(); canvas.drawCircle(width / 2, height * 0.65f, width / 3.5f + width * 0.38f * (((float) (mValue) - mMinValue) / (mMaxValue - mMinValue)), mRadialPaint); scaleSieveIfNeeded(width); Paint p2 = new Paint(); p2.setAntiAlias(true); canvas.drawBitmap(mSieveScaledBitmap, 0, 0, p2); }
private HolographicOutlineHelper(Context context) { final float scale = LauncherAppState.getInstance().getScreenDensity(); mMediumOuterBlurMaskFilter = new BlurMaskFilter(scale * 2.0f, BlurMaskFilter.Blur.OUTER); mThinOuterBlurMaskFilter = new BlurMaskFilter(scale * 1.0f, BlurMaskFilter.Blur.OUTER); mMediumInnerBlurMaskFilter = new BlurMaskFilter(scale * 2.0f, BlurMaskFilter.Blur.NORMAL); mShaowBlurMaskFilter = new BlurMaskFilter(scale * 4.0f, BlurMaskFilter.Blur.NORMAL); mShadowOffset = (int) (scale * 2.0f); shadowBitmapPadding = (int) (scale * 4.0f); mDrawPaint.setFilterBitmap(true); mDrawPaint.setAntiAlias(true); mBlurPaint.setFilterBitmap(true); mBlurPaint.setAntiAlias(true); mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); mErasePaint.setFilterBitmap(true); mErasePaint.setAntiAlias(true); }
/** * 为指定图片增加阴影 * * @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; }
@Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); mRect.set(bounds); mShadowRect.set(mRect); mShadowRect.inset(mShadowSize, mShadowSize); if (mFullCircle) { mCornerRadius = Math.abs(mRect.left - mRect.right) / 2; } if (mBorderSize > 0) { initRectsWithBorders(); } else { initRectsWithoutBorders(); } if(mShadowSize > 0) { mShadowMaskFilter = new BlurMaskFilter(mShadowSize * 0.95F, BlurMaskFilter.Blur.SOLID); } updateShaderMatrix(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_blur_mask_filter); LinearLayout container = (LinearLayout) findViewById(R.id.container); for (BlurMaskFilter.Blur style : BlurMaskFilter.Blur.values()) { TextView textView = new TextView(this); textView.setTextAppearance(this, R.style.TextAppearance_Huge_Green); applyFilter(textView, style); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; container.addView(textView, params); } }
@Override public void setParameter(ZDepthParam param, int left, int top, int right, int bottom) { mRectTopShadow.left = left; mRectTopShadow.top = (int) (top + param.mOffsetYTopShadowPx); mRectTopShadow.right = right; mRectTopShadow.bottom = (int) (bottom + param.mOffsetYTopShadowPx); mRectBottomShadow.left = left; mRectBottomShadow.top = (int) (top + param.mOffsetYBottomShadowPx); mRectBottomShadow.right = right; mRectBottomShadow.bottom = (int) (bottom + param.mOffsetYBottomShadowPx); mTopShadow.getPaint().setColor(Color.argb(param.mAlphaTopShadow, 0, 0, 0)); if (0 < param.mBlurTopShadowPx) { mTopShadow.getPaint().setMaskFilter(new BlurMaskFilter(param.mBlurTopShadowPx, BlurMaskFilter.Blur.NORMAL)); } else { mTopShadow.getPaint().setMaskFilter(null); } mBottomShadow.getPaint().setColor(Color.argb(param.mAlphaBottomShadow, 0, 0, 0)); if (0 < param.mBlurBottomShadowPx) { mBottomShadow.getPaint().setMaskFilter(new BlurMaskFilter(param.mBlurBottomShadowPx, BlurMaskFilter.Blur.NORMAL)); } else { mBottomShadow.getPaint().setMaskFilter(null); } }
@Override public void setParameter(ZDepthParam param, int left, int top, int right, int bottom) { mRectTopShadow.left = left; mRectTopShadow.top = top + param.mOffsetYTopShadowPx; mRectTopShadow.right = right; mRectTopShadow.bottom = bottom + param.mOffsetYTopShadowPx; mRectBottomShadow.left = left; mRectBottomShadow.top = top + param.mOffsetYBottomShadowPx; mRectBottomShadow.right = right; mRectBottomShadow.bottom = bottom + param.mOffsetYBottomShadowPx; mTopShadow.getPaint().setColor(Color.argb(param.mAlphaTopShadow, 0, 0, 0)); if (0 < param.mBlurTopShadowPx) { mTopShadow.getPaint().setMaskFilter(new BlurMaskFilter(param.mBlurTopShadowPx, BlurMaskFilter.Blur.NORMAL)); } else { mTopShadow.getPaint().setMaskFilter(null); } mBottomShadow.getPaint().setColor(Color.argb(param.mAlphaBottomShadow, 0, 0, 0)); if (0 < param.mBlurBottomShadowPx) { mBottomShadow.getPaint().setMaskFilter(new BlurMaskFilter(param.mBlurBottomShadowPx, BlurMaskFilter.Blur.NORMAL)); } else { mBottomShadow.getPaint().setMaskFilter(null); } }
private static void initStatics(Context context) { final Resources resources = context.getResources(); final DisplayMetrics metrics = resources.getDisplayMetrics(); final float density = metrics.density; sIconWidth = sIconHeight = (int) resources.getDimension(R.dimen.app_icon_size); sIconTextureWidth = sIconTextureHeight = sIconWidth; sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL)); sGlowColorPressedPaint.setColor(0xffffc300); sGlowColorPressedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30)); sGlowColorFocusedPaint.setColor(0xffff8e00); sGlowColorFocusedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30)); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0.2f); sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm)); sDisabledPaint.setAlpha(0x88); }
private static void initStatics(Context context) { final Resources resources = context.getResources(); final DisplayMetrics metrics = resources.getDisplayMetrics(); final float density = metrics.density; sIconWidth = sIconHeight = (int) resources .getDimension(R.dimen.app_icon_size); sIconTextureWidth = sIconTextureHeight = sIconWidth + 2; sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL)); sGlowColorPressedPaint.setColor(0xffffc300); sGlowColorPressedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30)); sGlowColorFocusedPaint.setColor(0xffff8e00); sGlowColorFocusedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30)); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0.2f); sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm)); sDisabledPaint.setAlpha(0x88); }
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)); }