This method creates a pastel color based on the given Color object. This is especially useful if you have a Color object that is either light or dark and want to make a pastel color out of it.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
public static Color generatePastelColor(Color mix) { Random random = new Random(); int red = random.nextInt(256); int green = random.nextInt(256); int blue = random.nextInt(256); // mix the color if (mix != null) { red = (red + mix.getRed()) / 2; green = (green + mix.getGreen()) / 2; blue = (blue + mix.getBlue()) / 2; } Color color = new Color(red, green, blue); return color; } |