Java Random Color getRandomColor(int saturationRandom, float luminance)

Here you can find the source of getRandomColor(int saturationRandom, float luminance)

Description

get Random Color

License

Open Source License

Declaration

public static Color getRandomColor(int saturationRandom, float luminance) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *     DarkForge a Forge Hacked Client//from w w w . j a  v a2  s  .co  m
 *     Copyright (C) 2017  Hexeption (Keir Davis)
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/

import java.awt.*;

import java.util.Random;

public class Main {
    private static final Random random = new Random();

    public static Color getRandomColor(int saturationRandom, float luminance) {

        final float hue = random.nextFloat();
        final float saturation = (random.nextInt(saturationRandom) + (float) saturationRandom)
                / (float) saturationRandom + (float) saturationRandom;
        return getHSBColor(hue, saturation, luminance);
    }

    public static Color getRandomColor() {

        return getRandomColor(1000, 0.6f);
    }

    public static Color getHSBColor(float hue, float sturation, float luminance) {

        return Color.getHSBColor(hue, sturation, luminance);
    }
}

Related

  1. getRandomColor()
  2. getRandomColor()
  3. getRandomColor()
  4. getRandomColor(boolean useTransparency)
  5. getRandomColor(float offset, float alpha)
  6. getRandomColorInString()
  7. getRandomColour()
  8. getRandomHexColor()
  9. getRandomHexColor()