Package ghidra.util

Class ColorUtils


  • public class ColorUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ColorUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.Color blend​(java.awt.Color c1, java.awt.Color c2, float ratio)
      Takes the first color, blending into it the second color, using the given ratio.
      static java.awt.Color contrastForegroundColor​(java.awt.Color color)
      A method to produce a color (either black or white) that contrasts with the given color.
      static java.awt.Color deriveBackground​(java.awt.Color background, float hue)  
      static java.awt.Color deriveBackground​(java.awt.Color src, float hue, float sfact, float bfact)  
      static java.awt.Color deriveForeground​(java.awt.Color bg, float hue)  
      static java.awt.Color deriveForeground​(java.awt.Color bg, float hue, float brt)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ColorUtils

        public ColorUtils()
    • Method Detail

      • deriveBackground

        public static java.awt.Color deriveBackground​(java.awt.Color src,
                                                      float hue,
                                                      float sfact,
                                                      float bfact)
      • deriveBackground

        public static java.awt.Color deriveBackground​(java.awt.Color background,
                                                      float hue)
      • deriveForeground

        public static java.awt.Color deriveForeground​(java.awt.Color bg,
                                                      float hue,
                                                      float brt)
      • deriveForeground

        public static java.awt.Color deriveForeground​(java.awt.Color bg,
                                                      float hue)
      • contrastForegroundColor

        public static java.awt.Color contrastForegroundColor​(java.awt.Color color)
        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

        public static java.awt.Color blend​(java.awt.Color c1,
                                           java.awt.Color c2,
                                           float ratio)
        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 color
        c2 - the second color
        ratio - the amount of the first color to include in the final output
        Returns:
        the new color