public class ColorUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
TEXTUTE_ID_SAMPLE1 |
static String |
TEXTUTE_ID_SAMPLE2 |
static String |
TEXTUTE_ID_SAMPLE3 |
static String |
TEXTUTE_ID_SAMPLE4 |
static String |
TEXTUTE_ID_SAMPLE5 |
| Constructor and Description |
|---|
ColorUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Color |
addColors(Color c1,
Color c2,
double amt) |
static Color |
blendColors(Color c1,
Color c2,
double amt) |
static Color |
blendColors(Color c1,
Paint c2,
double amt) |
static Color |
blendColors(Paint c1,
Color c2,
double amt) |
static Color |
changeAlpha(Color c,
int alpha) |
static float[] |
convertColor(Color color)
Returns an array of color components for the given Color object.
|
static void |
convertColor(Color color,
float[] destination)
Places the RGBA values from the given Color object into the destination
array.
|
static Color |
convertColor(float[] color)
Returns a new Color object given the color components in the given array.
|
static String |
formatColor(Color s) |
static String |
formatPaint(Paint s) |
static int |
getBrightness(Color color)
Uses the method described at http://alienryderflex.com/hsp.html to get
the perceived brightness of a color.
|
static int |
getBrightness(Paint color) |
static TexturePaint |
getCheckerBoard(int checkerSize,
Color color1,
Color color2) |
static Color |
getColor(Color color,
float factor)
Returns a new color that is darker or lighter than the given color by the
given factor.
|
static Color |
getForegroundColorFromBackgroundColor(Color color)
Returns a foreground color (for text) given a background color by
examining the brightness of the background color.
|
static Color |
getForegroundColorFromBackgroundColor(Paint color)
Returns a foreground color (for text) given a background color by
examining the brightness of the background color.
|
static Color |
getInvertColor(Color color)
Returns a foreground color (for text) given a background color by
examining the brightness of the background color.
|
static Color |
getRandomColor(float offset,
float alpha)
Returns a random color given the offset and alpha values.
|
static Color |
paintToColor(Paint color) |
static Color |
parseColor(String s) |
static Paint |
parsePaint(String s) |
public static final String TEXTUTE_ID_SAMPLE1
public static final String TEXTUTE_ID_SAMPLE2
public static final String TEXTUTE_ID_SAMPLE3
public static final String TEXTUTE_ID_SAMPLE4
public static final String TEXTUTE_ID_SAMPLE5
public static TexturePaint getCheckerBoard(int checkerSize, Color color1, Color color2)
public static final Color getForegroundColorFromBackgroundColor(Paint color)
color - the foreground colorpublic static final float[] convertColor(Color color)
color - the color objectpublic static final Color convertColor(float[] color)
color - the color components in RGB or RGBApublic static final void convertColor(Color color, float[] destination)
color - the color to convertdestination - the array to hold the RGBA values; length 4public static final int getBrightness(Paint color)
public static final int getBrightness(Color color)
color - the colorpublic static final Color getForegroundColorFromBackgroundColor(Color color)
color - the foreground colorpublic static final Color getInvertColor(Color color)
color - the foreground colorpublic static final Color getRandomColor(float offset, float alpha)
offset - the offset between 0.0 and 1.0alpha - the alpha value between 0.0 and 1.0public static final Color getColor(Color color, float factor)
color - the color to modifyfactor - 0.0 ≤ factor ≤ 1.0 darkens; 1.0 < factor brightensCopyright © 2021 vpc open source initiative. All rights reserved.