Class ColorUtils
java.lang.Object
net.thevpc.common.swing.color.ColorUtils
- Author:
- thevpc
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Colorstatic ColorblendColors(Color c1, Color c2, double amt) static ColorblendColors(Color c1, Paint c2, double amt) static ColorblendColors(Paint c1, Color c2, double amt) static ColorchangeAlpha(Color c, int alpha) / g.drawLine(0, h/2, w, h/2); / g.drawLine(0, h, w, h); / break; / } / }static final ColorconvertColor(float[] color) Returns a new Color object given the color components in the given array.static final float[]convertColor(Color color) Returns an array of color components for the given Color object.static final voidconvertColor(Color color, float[] destination) Places the RGBA values from the given Color object into the destination array.static StringformatColor(Color s) static StringformatPaint(Paint s) static final intgetBrightness(Color color) Uses the method described at http://alienryderflex.com/hsp.html to get the perceived brightness of a color.static final intgetBrightness(Paint color) static TexturePaintgetCheckerBoard(int checkerSize, Color color1, Color color2) static final ColorReturns a new color that is darker or lighter than the given color by the given factor.static final ColorReturns a foreground color (for text) given a background color by examining the brightness of the background color.static final ColorReturns a foreground color (for text) given a background color by examining the brightness of the background color.static final ColorgetInvertColor(Color color) Returns a foreground color (for text) given a background color by examining the brightness of the background color.static final ColorgetRandomColor(float offset, float alpha) Returns a random color given the offset and alpha values.static ColorpaintToColor(Paint color) static ColorparseColor(String s) static PaintparsePaint(String s)
-
Field Details
-
TEXTUTE_ID_SAMPLE1
- See Also:
-
TEXTUTE_ID_SAMPLE2
- See Also:
-
TEXTUTE_ID_SAMPLE3
- See Also:
-
TEXTUTE_ID_SAMPLE4
- See Also:
-
TEXTUTE_ID_SAMPLE5
- See Also:
-
-
Constructor Details
-
ColorUtils
public ColorUtils()
-
-
Method Details
-
formatPaint
-
parseColor
-
formatColor
-
parsePaint
-
getCheckerBoard
-
changeAlpha
-
blendColors
-
blendColors
-
getForegroundColorFromBackgroundColor
-
blendColors
-
addColors
-
convertColor
Returns an array of color components for the given Color object.- Parameters:
color- the color object- Returns:
- float[]
-
convertColor
Returns a new Color object given the color components in the given array.- Parameters:
color- the color components in RGB or RGBA- Returns:
- Color
-
convertColor
Places the RGBA values from the given Color object into the destination array.- Parameters:
color- the color to convertdestination- the array to hold the RGBA values; length 4
-
getBrightness
-
getBrightness
Uses the method described at http://alienryderflex.com/hsp.html to get the perceived brightness of a color.- Parameters:
color- the color- Returns:
- int brightness on the scale of 0 to 255
-
getForegroundColorFromBackgroundColor
-
getInvertColor
-
getRandomColor
Returns a random color given the offset and alpha values.- Parameters:
offset- the offset between 0.0 and 1.0alpha- the alpha value between 0.0 and 1.0- Returns:
- Color
-
getColor
-
paintToColor
-