Example usage for android.graphics Color rgb

List of usage examples for android.graphics Color rgb

Introduction

In this page you can find the example usage for android.graphics Color rgb.

Prototype

@ColorInt
public static int rgb(float red, float green, float blue) 

Source Link

Document

Return a color-int from red, green, blue float components in the range \([0..1]\).

Usage

From source file:Main.java

public static int generateBeautifulColor() {
    Random random = new Random();

    int red = 30 + random.nextInt(200);
    int green = 30 + random.nextInt(200);
    int blue = 30 + random.nextInt(200);
    return Color.rgb(red, green, blue);
}

From source file:Main.java

public static int genrateBeautifulColor() {
    Random random = new Random();

    int red = 30 + random.nextInt(200);
    int green = 30 + random.nextInt(200);
    int blue = 30 + random.nextInt(200);

    return Color.rgb(red, green, blue);
}

From source file:Main.java

public static int randomColor() {
    Random random = new Random();
    int red = random.nextInt(150) + 50;//50-199
    int green = random.nextInt(150) + 50;//50-199
    int blue = random.nextInt(150) + 50;//50-199
    return Color.rgb(red, green, blue);
}

From source file:Main.java

public static int makePressColor(int color) {
    int r = (color >> 16) & 0xFF;
    int g = (color >> 8) & 0xFF;
    int b = (color) & 0xFF;
    r = (r - 30 < 0) ? 0 : r - 30;/*from www .java  2s.  c  o  m*/
    g = (g - 30 < 0) ? 0 : g - 30;
    b = (b - 30 < 0) ? 0 : b - 30;
    return Color.rgb(r, g, b);
}

From source file:Main.java

public static int lighterColor(int color, int lighter) {
    int r = Math.max(Math.min(Color.red(color) + lighter, 255), 0);
    int g = Math.max(Math.min(Color.green(color) + lighter, 255), 0);
    int b = Math.max(Math.min(Color.blue(color) + lighter, 255), 0);
    return Color.rgb(r, g, b);
}

From source file:Main.java

public static int getDarkColor(int color) {
    int darkColor = 0;

    int r = Math.max(Color.red(color) - 25, 0);
    int g = Math.max(Color.green(color) - 25, 0);
    int b = Math.max(Color.blue(color) - 25, 0);

    darkColor = Color.rgb(r, g, b);

    return darkColor;
}

From source file:Main.java

/**
 * Returns an opaque version of the given color.
 * @param color Color for which an opaque version should be returned.
 * @return Opaque version of the given color.
 *///from  w ww .jav  a2 s.  c om
public static int getOpaqueColor(int color) {
    return Color.rgb(Color.red(color), Color.green(color), Color.blue(color));
}

From source file:Main.java

public static Bitmap getHapticMap(Context c, String syllable) {
    return drawTextToBitmap(c, syllable, Color.rgb(255, 255, 255), Color.rgb(0, 0, 0));
}

From source file:Main.java

/**
 * Get a random color/*w  w  w .j a  v a2  s  . c o m*/
 *
 * @return Random color
 */
public static int getRandomColor() {
    Random random = new Random();
    return Color.rgb(random.nextInt(sColor_Range), random.nextInt(sColor_Range), random.nextInt(sColor_Range));
}

From source file:Main.java

/**
 * Returns a darker version of the specified color. Returns a translucent gray for transparent colors.
 *///from w w w  . j a va  2 s .c om
private static int darkenColor(int color) {
    if (color == TRANSPARENT) {
        return Color.argb(127, 127, 127, 127);
    }
    return Color.rgb(Color.red(color) * 192 / 256, Color.green(color) * 192 / 256,
            Color.blue(color) * 192 / 256);
}