List of utility methods to do Color Create
Color[] | generateColorRamp(int n) Generates a red to blue color ramp with of 'n' colors Color[] cols = new Color[n]; for (int i = 0; i < n; i++) { cols[i] = Color.getHSBColor((float) i / (float) (n * 1.5), 0.75f, 1.0f); return cols; |
Color[] | generateColourSet(Color[] palette, int numColorBands) Gets a version of this palette with the given number of color bands, either by subsampling or interpolating the existing palette Color[] targetPalette; if (numColorBands == palette.length) { targetPalette = palette; } else { targetPalette = new Color[numColorBands]; targetPalette[0] = palette[0]; targetPalette[targetPalette.length - 1] = palette[palette.length - 1]; if (targetPalette.length < palette.length) { ... |
Color | generateFireMapColor(double min, double max, double value) generate Fire Map Color assert value >= min && value <= max; if (value < min || value > max) { throw new IllegalArgumentException("Value must be between min and max values, it was not."); double power = (value - min) / (max - min); double H = Math.abs(0.138 - power * 0.138); double S = 1; double B = Math.abs(0.5 - power * 0.5) + 0.5; ... |
Color | generateGrayScaleColor(double min, double max, double value) generate Gray Scale Color assert value >= min && value <= max; if (value < min || value > max) { throw new IllegalArgumentException("Value must be between min and max values, it was not."); double power = (value - min) / (max - min); return Color.getHSBColor(0, 0, 1 - (float) power); |
Color | generateGreyColor(double value, double minValue, double maxValue) generate Grey Color int colorValue = (int) ((value + 1.0D) / 2.0D * 245.0D + 10.0D); colorValue = 255 - colorValue; return new Color(colorValue, colorValue, colorValue); |
String | generateHexolor(Color color) generate Hexolor String r = Integer.toHexString(color.getRed()); if (r.length() < 2) { r = "0" + r; String g = Integer.toHexString(color.getGreen()); if (g.length() < 2) { g = "0" + g; String b = Integer.toHexString(color.getBlue()); if (b.length() < 2) { b = "0" + b; return "#" + r + g + b; |
Color[] | generateNColors(int numColors) Generates a series of colors such that the distribution of the colors is (fairly) evenly spaced throughout the color spectrum. Color[] table = new Color[numColors]; if (numColors == 1) { table[0] = Color.red; } else { float hueMax = (float) 0.85; float sat = (float) 0.8; for (int i = 0; i < numColors; i++) { float hue = hueMax * i / (numColors - 1); ... |
int | generateNextValidColor() generate Next Valid Color int step = 1; redValue += step; if (redValue == 256) { greenValue += step; redValue = 0; if (greenValue == 256) { blueValue += step; greenValue = 0; ... |
List | generatePallete(final int colours) generate Pallete final List<Color> pallete = new ArrayList<Color>(colours); for (int i = 0; i < colours; i++) { pallete.add(generateColour()); return pallete; |
Color | generateRGBRandomColor() Generate random RGB color. Random random = new Random(); int red = random.nextInt(256); int green = random.nextInt(256); int blue = random.nextInt(256); return new Color(red, green, blue); |