Java Random Color randomDesaturatedColor(float alpha)

Here you can find the source of randomDesaturatedColor(float alpha)

Description

random Desaturated Color

License

LGPL

Declaration

public static Color randomDesaturatedColor(float alpha) 

Method Source Code

//package com.java2s;
/*//from w ww.j av a 2  s.  c  om
 * Copyright (c) 2007-2012 The Broad Institute, Inc.
 * SOFTWARE COPYRIGHT NOTICE
 * This software and its documentation are the copyright of the Broad Institute, Inc. All rights are reserved.
 *
 * This software is supplied without any warranty or guaranteed support whatsoever. The Broad Institute is not responsible for its use, misuse, or functionality.
 *
 * This software is licensed under the terms of the GNU Lesser General Public License (LGPL),
 * Version 2.1 which is available at http://www.opensource.org/licenses/lgpl-2.1.php.
 */

import java.awt.*;

public class Main {
    public static Color randomDesaturatedColor(float alpha) {
        float hue = (float) Math.random();
        float brightenss = (float) (Math.random() * 0.7);
        Color base = Color.getHSBColor(hue, 0, brightenss);
        if (alpha >= 1)
            return base;
        else
            return new Color(base.getRed(), base.getGreen(), base.getBlue(), (int) (alpha * 255));

    }
}

Related

  1. randomColor(Random r)
  2. randomColorFactor()
  3. randomColorValue()
  4. randomColour(Random random)
  5. randomDarkColor()