Package 

Class ColorUtil


  • 
    public class ColorUtil
    
                        

    Simple utility class for manipulating colors, based on Fresco's DrawableUtils (https://github.com/facebook/fresco). For a small helper like this, copying is simpler than adding a dependency on com.facebook.fresco.drawee.

    • Method Summary

      Modifier and Type Method Description
      static int multiplyColorAlpha(int color, int alpha) Multiplies the color with the given alpha.
      static int getOpacityFromColor(int color) Gets the opacity from a color.
      static int normalize(double r, double g, double b, double a) Converts individual {r, g, b, a} channel values to a single integer representation of the coloras 0xAARRGGBB.
      • Methods inherited from class java.lang.Object

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

      • multiplyColorAlpha

         static int multiplyColorAlpha(int color, int alpha)

        Multiplies the color with the given alpha.

        Parameters:
        color - color to be multiplied
        alpha - value between 0 and 255
      • getOpacityFromColor

         static int getOpacityFromColor(int color)

        Gets the opacity from a color. Inspired by Android ColorDrawable.

        Parameters:
        color - color to get opacity from
      • normalize

         static int normalize(double r, double g, double b, double a)

        Converts individual {r, g, b, a} channel values to a single integer representation of the coloras 0xAARRGGBB.

        Parameters:
        r - red channel value, [0, 255]
        g - green channel value, [0, 255]
        b - blue channel value, [0, 255]
        a - alpha channel value, [0, 1]