Advertisement
psi_mmobile

Untitled

Mar 12th, 2021
834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1.     public ArrayList<String> colorArrayGenerator (int numberOfIterations) {
  2.         ArrayList<String> colorArray = new ArrayList<String>();
  3.         for (int i = 0; i < numberOfIterations;i++) {
  4.             int red = (int)(Math.random()*256);
  5.             int green = (int)(Math.random()*256);
  6.             int blue= (int)(Math.random()*256);
  7.             Color randomColor = new Color(red,green,blue);
  8.             Random rand = new Random();
  9.             final float hue = rand.nextFloat();
  10.             final float saturation = 0.9f;//1.0 for brilliant, 0.0 for dull
  11.             final float luminance = 0.5f; //1.0 for brighter, 0.0 for black
  12.             randomColor = Color.getHSBColor(hue, saturation, luminance);
  13.             String hex = String.format("#%02x%02x%02x", randomColor.getRed(), randomColor.getGreen(), randomColor.getBlue());
  14.             colorArray.add(hex);
  15.         }
  16.         return colorArray;
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement