001/******************************************************************************* 002 * This software is provided as a supplement to the authors' textbooks on digital 003 * image processing published by Springer-Verlag in various languages and editions. 004 * Permission to use and distribute this software is granted under the BSD 2-Clause 005 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause). 006 * Copyright (c) 2006-2016 Wilhelm Burger, Mark J. Burge. All rights reserved. 007 * Visit http://imagingbook.com for additional details. 008 *******************************************************************************/ 009 010package imagingbook.lib.color; 011 012import java.awt.Color; 013import java.util.Random; 014 015public class RandomColorGenerator { 016 017 private float h = 0.0f; 018 private float s = 0.9f; 019 private float b = 0.9f; 020 Random rnd; 021 022 public RandomColorGenerator() { 023 rnd = new Random(1); 024 } 025 026 public RandomColorGenerator(int seed) { 027 rnd = new Random(seed); 028 } 029 030 public Color nextColor() { 031 //h = (h + 0.8f + 0.3f * (float)rnd.nextGaussian()) % 1.0f; 032 //h = (float) (h + rnd.nextGaussian()) % 1.0f; 033 h = (float) (h + 0.1 + 0.8f * rnd.nextFloat()) % 1.0f; 034 return Color.getHSBColor(h, s, b); 035 } 036 037}