Package ghidra.util
Class ColorUtils
java.lang.Object
ghidra.util.ColorUtils
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic Comparator
<Color> A colorComparator
for ordering colors.static final float
static final float
static final float
static final float
static final float
static final float
static final float
static final float
static final float
static final float
static final float
static final float
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Color
Combines colors in a way the makes them stand out from each other more than just averaging them together.static Color
Creates a new color by averaging the red, green, blue, and alpha values from the given colors.static Color
Takes the first color, blending into it the second color, using the given ratio.static Color
contrastForegroundColor
(Color color) A method to produce a color (either black or white) that contrasts with the given color.static Color
deriveBackground
(Color background, float hue) static Color
deriveBackground
(Color src, float hue, float sfact, float bfact) static Color
deriveForeground
(Color bg, float hue) static Color
deriveForeground
(Color bg, float hue, float brt) static Color
getColor
(int rgba) Return the color object given a rgba value that includes the desired alpha value.static Color
getColor
(int red, int green, int blue) Return an opaque color object given for the given red, green, and blue values.static Color
getColor
(int red, int green, int blue, int alpha) Return the color object given for the given red, green, blue, and alpha values.static Color
getOpaqueColor
(int rgb) Returns an opaque color with the given rgb value.static Color
Returns a new color that is comprised of the given color's rgb value and the given alpha value.
-
Field Details
-
HUE_RED
public static final float HUE_RED- See Also:
-
HUE_ORANGE
public static final float HUE_ORANGE- See Also:
-
HUE_YELLOW
public static final float HUE_YELLOW- See Also:
-
HUE_LIME
public static final float HUE_LIME- See Also:
-
HUE_GREEN
public static final float HUE_GREEN- See Also:
-
HUE_PINE
public static final float HUE_PINE- See Also:
-
HUE_TURQUISE
public static final float HUE_TURQUISE- See Also:
-
HUE_SAPPHIRE
public static final float HUE_SAPPHIRE- See Also:
-
HUE_BLUE
public static final float HUE_BLUE- See Also:
-
HUE_ROYAL
public static final float HUE_ROYAL- See Also:
-
HUE_PURPLE
public static final float HUE_PURPLE- See Also:
-
HUE_PINK
public static final float HUE_PINK- See Also:
-
COMPARATOR
A colorComparator
for ordering colors.
-
-
Constructor Details
-
ColorUtils
public ColorUtils()
-
-
Method Details
-
deriveBackground
-
deriveBackground
-
deriveForeground
-
deriveForeground
-
contrastForegroundColor
A method to produce a color (either black or white) that contrasts with the given color. This is useful for finding a readable foreground color for a given background.- Parameters:
color
- the color for which to find a contrast.- Returns:
- the contrasting color.
-
blend
Takes the first color, blending into it the second color, using the given ratio. A lower ratio (say .1f) signals to use very little of the first color; a larger ratio signals to use more of the first color.- Parameters:
c1
- the first colorc2
- the second colorratio
- the amount of the first color to include in the final output- Returns:
- the new color
-
addColors
Combines colors in a way the makes them stand out from each other more than just averaging them together. Basically if the colors are bright, the result is a darker value than the primary, adjusted based on the values in the secondary. If the colors are dark, then the result is a brighter version of the primary color adjusted based on values in the secondary color.- Parameters:
primary
- the primary color to be tweakedsecondary
- the color to used to determine the amount to tweak the red,green,blue values- Returns:
- a new color that is a combination of the two colors
-
withAlpha
Returns a new color that is comprised of the given color's rgb value and the given alpha value.- Parameters:
c
- the coloralpha
- the alpha- Returns:
- the new color
-
getColor
Return the color object given a rgba value that includes the desired alpha value.- Parameters:
rgba
- value where bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue- Returns:
- the color object given a rgba value that includes the desired alpha value
-
getColor
Return an opaque color object given for the given red, green, and blue values.- Parameters:
red
- the red value (0 - 255)green
- the green value (0 - 255)blue
- the blue value (0 - 255)- Returns:
- the color object for the given values
-
getColor
Return the color object given for the given red, green, blue, and alpha values.- Parameters:
red
- the red value (0 - 255)green
- the green value (0 - 255)blue
- the blue value (0 - 255)alpha
- the alpha (transparency) value (0 - 255) with 0 being fully transparent and 255 being fully opaque opaque- Returns:
- the color object for the given values
-
getOpaqueColor
Returns an opaque color with the given rgb value. The resulting color will have an alpha value of 0xff.- Parameters:
rgb
- the value where bits 16-23 are red, 8-15 are green, 0-7 are blue. Bits 24-31 will be set to 0xff.- Returns:
- an opaque color with the given rgb value
-
average
Creates a new color by averaging the red, green, blue, and alpha values from the given colors.- Parameters:
color1
- the first color to averagecolor2
- the second color to average- Returns:
- a new color that is the average of the two given colors
-