Exemplo n.º 1
0
 /**
  * Derives the ARGB value for a color based on an offset between two other colors.
  *
  * @param color1 The first color
  * @param color2 The second color
  * @param midPoint The offset between color 1 and color 2, a value of 0.0 is color 1 and 1.0 is
  *     color 2;
  * @return the ARGB value for a new color based on this derivation
  */
 static int deriveARGB(Color color1, Color color2, float midPoint) {
   int r = color1.getRed() + Math.round((color2.getRed() - color1.getRed()) * midPoint);
   int g = color1.getGreen() + Math.round((color2.getGreen() - color1.getGreen()) * midPoint);
   int b = color1.getBlue() + Math.round((color2.getBlue() - color1.getBlue()) * midPoint);
   int a = color1.getAlpha() + Math.round((color2.getAlpha() - color1.getAlpha()) * midPoint);
   return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
 }