List of usage examples for android.graphics Color alpha
@IntRange(from = 0, to = 255) public static int alpha(int color)
From source file:Main.java
public static int darker(int color, float factor) { return Color.argb(Color.alpha(color), Math.max((int) (Color.red(color) * factor), 0), Math.max((int) (Color.green(color) * factor), 0), Math.max((int) (Color.blue(color) * factor), 0)); }
From source file:Main.java
public static int colorToColor(int i, int j, float f) { int k = Color.alpha(i); int l = Color.red(i); int i1 = Color.green(i); int j1 = Color.blue(i); int k1 = Color.alpha(j); int l1 = Color.red(j); int i2 = Color.green(j); int j2 = Color.blue(j); return Color.argb((int) (f * (float) k1 + (float) k * (1.0F - f)), (int) (f * (float) l1 + (float) l * (1.0F - f)), (int) (f * (float) i2 + (float) i1 * (1.0F - f)), (int) (f * (float) j2 + (float) j1 * (1.0F - f))); }
From source file:Main.java
private static int blendColors(int i, int i2, float f) { float f2 = 1.0f - f; return Color.argb((int) ((((float) Color.alpha(i)) * f2) + (((float) Color.alpha(i2)) * f)), (int) ((((float) Color.red(i)) * f2) + (((float) Color.red(i2)) * f)), (int) ((((float) Color.green(i)) * f2) + (((float) Color.green(i2)) * f)), (int) ((f2 * ((float) Color.blue(i))) + (((float) Color.blue(i2)) * f))); }
From source file:Main.java
public static int transformIfTooWhite(int color) { int alpha = Color.alpha(color); int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); float whiteRatio = (red + green + blue) / 3f / 255f * (alpha / 255f); float transformRatio = 0.7f; if (whiteRatio > transformRatio) { red *= transformRatio;/*from w w w.j a v a 2 s . co m*/ green *= transformRatio; blue *= transformRatio; color = Color.argb(alpha, red, green, blue); } return color; }
From source file:Main.java
public static int interpolate(int c1, int c2, float f) { int alpha = (int) ((Color.alpha(c2) - Color.alpha(c1)) * f) + Color.alpha(c1); int red = (int) ((Color.red(c2) - Color.red(c1)) * f) + Color.red(c1); int green = (int) ((Color.green(c2) - Color.green(c1)) * f) + Color.green(c1); int blue = (int) ((Color.blue(c2) - Color.blue(c1)) * f) + Color.blue(c1); //Log.v("ColorHelper","alpha = "+alpha); return Color.argb(alpha, red, green, blue); }
From source file:Main.java
public static int getColor(int baseColor, float alphaPercent) { int alpha = Math.round(Color.alpha(baseColor) * alphaPercent); return (baseColor & 0x00FFFFFF) | (alpha << 24); }
From source file:Main.java
public static int getPrimaryDarkColor(int color) { double tran = 0.8; int a = Color.alpha(color); int r = Color.red(color); int g = Color.green(color); int b = Color.blue(color); return Color.argb(a, Math.max((int) (r * tran), 0), Math.max((int) (g * tran), 0), Math.max((int) (b * tran), 0)); }
From source file:Main.java
public static final String convertToColorCode(int color) { int alpha = Color.alpha(color); int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); return String.format(Locale.getDefault(), "%02x%02x%02x%02x", alpha, red, green, blue); }
From source file:Main.java
public static int getColor(int baseColor, float alphaPercent) { return (baseColor & 0x00FFFFFF) | (Math.round(Color.alpha(baseColor) * alphaPercent) << 24); }
From source file:Main.java
public static int adjustAlpha(int color, @SuppressWarnings("SameParameterValue") float factor) { int alpha = Math.round(Color.alpha(color) * factor); int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); return Color.argb(alpha, red, green, blue); }