List of usage examples for android.graphics Color BLACK
int BLACK
To view the source code for android.graphics Color BLACK.
Click Source Link
From source file:CustomView.java
public CustomView(Context context) { super(context); mPaint.setColor(Color.BLACK); mPaint.setTextSize(30); }
From source file:Main.java
public static Bitmap getRoundBitmap(Bitmap bmp, float roundDP) { // roundDP *= Constants.screen_density; Bitmap bmpOut = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Config.ARGB_8888); Canvas c = new Canvas(bmpOut); final Paint p = new Paint(); final RectF rectF = new RectF(0, 0, bmp.getWidth(), bmp.getHeight()); p.setAntiAlias(true);//from w ww . ja v a 2 s . co m c.drawARGB(0, 0, 0, 0); p.setColor(Color.BLACK); c.drawRoundRect(rectF, roundDP, roundDP, p); p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); c.drawBitmap(bmp, 0, 0, p); return bmpOut; }
From source file:Main.java
public static int getContrastYIQ(int color, int threshold) { return getContrastYIQ(color, threshold, Color.BLACK, Color.WHITE); }
From source file:Main.java
/** * Create an spectrum color palette from a base color. Max 8 colors; after that * color are filled but with a reused color. *///from ww w . j av a 2 s . c o m public static int[] createMaterialSpectrumPalette(int color, final int count) { int[] palette = new int[count]; if (count > 0) { final boolean isDarkColor = isDarkColor(color); final float[] opacity = isDarkColor ? new float[] { .75f, .50f, .25f, .10f, .85f, .75f, .50f, .25f } : new float[] { .85f, .75f, .50f, .25f, .75f, .50f, .25f, .10f }; for (int i = 0; i < count; i++) { final int op = i % opacity.length; int mask = (isDarkColor && op < 4) || (!isDarkColor && op >= 4) ? Color.WHITE : Color.BLACK; float alpha = opacity[op]; palette[i] = applyMaskColor(color, mask, alpha); } } return palette; }
From source file:Main.java
public static Bitmap fillet(Bitmap bitmap, int pixels) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); final float roundPx = pixels; paint.setAntiAlias(true);//from w w w. ja v a 2s . c o m canvas.drawARGB(0, 0, 0, 0); paint.setColor(Color.BLACK); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; }
From source file:Main.java
/** * Gets the rounded corner bitmap.// ww w .ja v a 2s . c o m * * @param bitmap * the bitmap * @return the rounded corner bitmap */ public static Bitmap getRoundedCornerBitmap(Context context, Bitmap bitmap, Boolean create_circle) { DisplayMetrics mMetrics = context.getResources().getDisplayMetrics(); float mScaleFactor = mMetrics.density; Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = Color.BLACK; final Paint paint = new Paint(); int width = bitmap.getWidth(); int height = (bitmap.getHeight() > width) ? width : bitmap.getHeight(); final Rect rect = new Rect(0, 0, width, height); final RectF rectF = new RectF(rect); final float roundPx = (create_circle) ? (bitmap.getWidth() > 360) ? bitmap.getWidth() : 360 : 2; paint.setAntiAlias(true); paint.setColor(color); paint.setStyle(Paint.Style.FILL); canvas.drawARGB(0, 0, 0, 0); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); // draw border paint.setColor(Color.parseColor("#cccccc")); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(0.5F * mScaleFactor); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); return output; }
From source file:Main.java
/** * Frames the input bitmap in a circle.// ww w . j av a 2 s . com */ public static Bitmap frameBitmapInCircle(Bitmap input) { if (input == null) { return null; } // Crop the image if not squared. int inputWidth = input.getWidth(); int inputHeight = input.getHeight(); int targetX, targetY, targetSize; if (inputWidth >= inputHeight) { targetX = inputWidth / 2 - inputHeight / 2; targetY = 0; targetSize = inputHeight; } else { targetX = 0; targetY = inputHeight / 2 - inputWidth / 2; targetSize = inputWidth; } // Create an output bitmap and a canvas to draw on it. Bitmap output = Bitmap.createBitmap(targetSize, targetSize, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(output); // Create a black paint to draw the mask. Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.BLACK); // Draw a circle. canvas.drawCircle(targetSize / 2, targetSize / 2, targetSize / 2, paint); // Replace the black parts of the mask with the input image. paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(input, targetX /* left */, targetY /* top */, paint); return output; }
From source file:Main.java
private static int bitToRGB(int bit) { if (bit == 1) { return Color.WHITE; } else {//from w ww . j ava 2 s. c om return Color.BLACK; } }
From source file:com.berniesanders.fieldthebern.media.ResponseColor.java
/** * Returns the user displayable string based off the supplied response * * <item>(select support level)</item> * <item>Strongly for Bernie</item> * <item>Leaning for Bernie</item> * <item>Undecided</item>//from w ww.j a va 2 s.c o m * <item>Leaning against Bernie</item> * <item>Strongly against Bernie</item> * * TODO better way to do this?! */ public static int getColor(@CanvassResponse.Response final String response, Context context) { switch (response) { case CanvassResponse.UNKNOWN: return ContextCompat.getColor(context, R.color.bernie_grey); case CanvassResponse.STRONGLY_FOR: return ContextCompat.getColor(context, R.color.bernie_dark_blue); case CanvassResponse.LEANING_FOR: return ContextCompat.getColor(context, R.color.b_light_blue); case CanvassResponse.UNDECIDED: return ContextCompat.getColor(context, R.color.bernie_green); case CanvassResponse.LEANING_AGAINST: return ContextCompat.getColor(context, R.color.bernie_light_red); case CanvassResponse.STRONGLY_AGAINST: return ContextCompat.getColor(context, R.color.bernie_red); case CanvassResponse.ASKED_TO_LEAVE: return Color.BLACK; case CanvassResponse.NO_ONE_HOME: return Color.GRAY; default: return Color.WHITE; } }
From source file:com.keylesspalace.tusky.ThemeUtils.java
static @ColorInt int getColor(Context context, @AttrRes int attribute) { TypedValue value = new TypedValue(); if (context.getTheme().resolveAttribute(attribute, value, true)) { return value.data; } else {// www.j ava 2 s.c o m return Color.BLACK; } }