Advertisement
JonMerritt

Palette Checks

May 26th, 2015
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. /**Checks each color of an int[7], one by one for full transparency;
  2. *
  3. * if the color is opaque, it returns it,
  4. * if the color is fully transparent, the next color is checked,
  5. * if all colors are fully transparent, it returns a set default color.**/
  6.  
  7. public static int getPaletteColor(int[] pColors) {
  8. int pColorFinal;
  9. if (tCheck(pColors[0])) pColorFinal = pColors[0];
  10. else if (tCheck(pColors[1])) pColorFinal = pColors[1];
  11. else if (tCheck(pColors[2])) pColorFinal = pColors[2];
  12. else if (tCheck(pColors[3])) pColorFinal = pColors[3];
  13. else if (tCheck(pColors[4])) pColorFinal = pColors[4];
  14. else if (tCheck(pColors[5])) pColorFinal = pColors[5];
  15. else pColorFinal = pColors[6];
  16. return pColorFinal;}
  17.  
  18. /**Boolean that uses the default luminance double to check for transparency/opaqueness**/
  19. private static boolean tCheck(int c) {
  20. return ColorUtils.calculateLuminance(c) > 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement