List of usage examples for android.graphics Paint setColor
public void setColor(@ColorInt int color)
From source file:org.mariotaku.twidere.view.ShapedImageView.java
private void updateShadowBitmap() { if (useOutline()) return;// w w w. j a v a2 s .c o m final int width = getWidth(), height = getHeight(); if (width <= 0 || height <= 0) return; final int contentLeft = getPaddingLeft(), contentTop = getPaddingTop(), contentRight = width - getPaddingRight(), contentBottom = height - getPaddingBottom(); final int contentWidth = contentRight - contentLeft, contentHeight = contentBottom - contentTop; final float radius = mShadowRadius, dy = radius * 1.5f / 2; final int size = Math.round(Math.min(contentWidth, contentHeight) + radius * 2); mShadowBitmap = Bitmap.createBitmap(size, Math.round(size + dy), Config.ARGB_8888); Canvas canvas = new Canvas(mShadowBitmap); final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(0xFF000000 | mBackgroundPaint.getColor()); paint.setShadowLayer(radius, 0, radius * 1.5f / 2, SHADOW_START_COLOR); final RectF rect = new RectF(radius, radius, size - radius, size - radius); if (getStyle() == SHAPE_CIRCLE) { canvas.drawOval(rect, paint); paint.setShadowLayer(0, 0, 0, 0); paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR)); canvas.drawOval(rect, paint); } else { final float cr = getCalculatedCornerRadius(); canvas.drawRoundRect(rect, cr, cr, paint); paint.setShadowLayer(0, 0, 0, 0); paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR)); canvas.drawRoundRect(rect, cr, cr, paint); } invalidate(); }
From source file:org.thoughtcrime.securesms.scribbles.widget.MotionView.java
private void initEntityBorder(@NonNull MotionEntity entity) { // init stroke int strokeSize = getResources().getDimensionPixelSize(R.dimen.scribble_stroke_size); Paint borderPaint = new Paint(); borderPaint.setStrokeWidth(strokeSize); borderPaint.setAntiAlias(true);/*from w w w . j av a 2s . c o m*/ borderPaint.setColor(getContext().getResources().getColor(R.color.sticker_selected_color)); entity.setBorderPaint(borderPaint); }
From source file:com.example.android.common.view.DividerItemDecoration.java
public void drawHorizontal(Canvas c, RecyclerView parent) { final int top = parent.getPaddingTop(); final int bottom = parent.getHeight() - parent.getPaddingBottom(); Paint paint = new Paint(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); final int left = child.getRight() + params.rightMargin + Math.round(ViewCompat.getTranslationX(child)); final int right = left + mDivider.getIntrinsicHeight(); paint.setColor(Color.RED); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c);/*ww w. j a v a 2 s . co m*/ // c.drawRect(left, top, right, bottom, paint); } }
From source file:hku.fyp14017.blencode.ui.fragment.AddBrickFragment.java
public ImageView getGlowingBorder(Bitmap bitmap) { ImageView imageView = new ImageView(getActivity()); imageView.setBackgroundColor(Color.TRANSPARENT); imageView.setId(hku.fyp14017.blencode.R.id.drag_and_drop_list_view_image_view); Bitmap glowingBitmap = Bitmap.createBitmap(bitmap.getWidth() + 30, bitmap.getHeight() + 30, Bitmap.Config.ARGB_8888);//from w w w .ja va 2s . c o m Canvas glowingCanvas = new Canvas(glowingBitmap); Bitmap alpha = bitmap.extractAlpha(); Paint paintBlur = new Paint(); paintBlur.setColor(Color.WHITE); glowingCanvas.drawBitmap(alpha, 15, 15, paintBlur); BlurMaskFilter blurMaskFilter = new BlurMaskFilter(15.0f, BlurMaskFilter.Blur.OUTER); paintBlur.setMaskFilter(blurMaskFilter); glowingCanvas.drawBitmap(alpha, 15, 15, paintBlur); paintBlur.setMaskFilter(null); glowingCanvas.drawBitmap(bitmap, 15, 15, paintBlur); imageView.setImageBitmap(glowingBitmap); return imageView; }
From source file:com.android.cts.verifier.managedprovisioning.NfcTestActivity.java
/** * Creates a Bitmap image that contains red on white text with a specified margin. * @param text Text to be displayed in the image. * @return A Bitmap image with the above specification. *//*from ww w. j a v a2s . c om*/ private Bitmap createSampleImage(String text) { Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setTextSize(TEXT_SIZE); Rect rect = new Rect(); paint.getTextBounds(text, 0, text.length(), rect); int w = 2 * MARGIN + rect.right - rect.left; int h = 2 * MARGIN + rect.bottom - rect.top; Bitmap dest = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(); canvas.setBitmap(dest); paint.setColor(Color.WHITE); canvas.drawPaint(paint); paint.setColor(Color.RED); canvas.drawText(text, MARGIN - rect.left, MARGIN - rect.top, paint); return dest; }
From source file:com.nextgis.maplibui.fragment.ReorderedLayerView.java
/** * Returns a bitmap showing a screenshot of the view passed in. *///from ww w . j a va2 s . co m protected Bitmap getBitmapFromView(View v) { Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setColor(getResources().getColor(R.color.background_floating_material_light)); Rect rect = new Rect(0, 0, v.getWidth(), v.getHeight()); canvas.drawRect(rect, paint); v.draw(canvas); return bitmap; }
From source file:com.abhinavjhanwar.android.egg.neko.Cat.java
public Bitmap createLargeBitmap(Context context) { final Resources res = context.getResources(); final int w = res.getDimensionPixelSize(android.R.dimen.notification_large_icon_width); final int h = res.getDimensionPixelSize(android.R.dimen.notification_large_icon_height); Bitmap result = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(result); final Paint pt = new Paint(); float[] hsv = new float[3]; Color.colorToHSV(mBodyColor, hsv); hsv[2] = (hsv[2] > 0.5f) ? (hsv[2] - 0.25f) : (hsv[2] + 0.25f); pt.setColor(Color.HSVToColor(hsv)); pt.setFlags(Paint.ANTI_ALIAS_FLAG); float r = w / 2; canvas.drawCircle(r, r, r, pt);//w w w .j a v a 2 s . c o m int m = w / 10; slowDraw(canvas, m, m, w - m - m, h - m - m); return result; }
From source file:com.mn.tiger.widget.viewpager.TGPagerSlidingTabStrip.java
/** * /* w ww . j av a2 s . c o m*/ * @param canvas * @param rectPaint */ protected void onDrawUnderLine(Canvas canvas, Paint rectPaint) { // draw underline rectPaint.setColor(underlineColor); canvas.drawRect(0, getHeight() - underlineHeight, tabsContainer.getWidth(), getHeight(), rectPaint); }
From source file:com.mn.tiger.widget.viewpager.TGPagerSlidingTabStrip.java
/** * /*from w w w .j a v a2 s. co m*/ * @param canvas * @param dividerPaint */ protected void onDrawDivider(Canvas canvas, Paint dividerPaint) { // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), getHeight() - dividerPadding, dividerPaint); } }
From source file:org.adw.library.widgets.discreteseekbar.internal.drawable.AlmostRippleDrawable.java
@Override public void doDraw(Canvas canvas, Paint paint) { Rect bounds = getBounds();//from w w w . j av a 2 s. c o m int size = Math.min(bounds.width(), bounds.height()); float scale = mCurrentScale; int rippleColor = mRippleColor; int bgColor = mRippleBgColor; float radius = (size / 2); float radiusAnimated = radius * scale; if (scale > INACTIVE_SCALE) { if (bgColor != 0) { paint.setColor(bgColor); paint.setAlpha(decreasedAlpha(Color.alpha(bgColor))); canvas.drawCircle(bounds.centerX(), bounds.centerY(), radius, paint); } if (rippleColor != 0) { paint.setColor(rippleColor); paint.setAlpha(modulateAlpha(Color.alpha(rippleColor))); canvas.drawCircle(bounds.centerX(), bounds.centerY(), radiusAnimated, paint); } } }