Java Color Create generatePallete(final int colours)

Here you can find the source of generatePallete(final int colours)

Description

generate Pallete

License

Open Source License

Declaration

public static List<Color> generatePallete(final int colours) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Main {
    public static List<Color> generatePallete(final int colours) {
        final List<Color> pallete = new ArrayList<Color>(colours);
        for (int i = 0; i < colours; i++) {
            pallete.add(generateColour());
        }//from  w  w  w  . ja v  a2 s  .co  m
        return pallete;
    }

    /**
     * Generates a completely random, pastel colour.
     * @return
     */
    public static Color generateColour() {
        final Random random = new Random();
        int red = random.nextInt(256);
        int green = random.nextInt(256);
        int blue = random.nextInt(256);

        // mix the color
        red = (red + 255) / 2;
        green = (green + 255) / 2;
        blue = (blue + 255) / 2;

        final Color color = new Color(red, green, blue);
        return color;
    }
}

Related

  1. generateGrayScaleColor(double min, double max, double value)
  2. generateGreyColor(double value, double minValue, double maxValue)
  3. generateHexolor(Color color)
  4. generateNColors(int numColors)
  5. generateNextValidColor()
  6. generateRGBRandomColor()
  7. generateTexturePaint(String text, Font font, Color textColor, Color bgColor, int width, int height)
  8. generateVisuallyDistinctColors(int ncolors, float minComponent, float maxComponent)
  9. toColor(byte red, byte green, byte blue)