get Gradient Bright Colors - Java 2D Graphics

Java examples for 2D Graphics:Color Dark

Description

get Gradient Bright Colors

Demo Code


//package com.java2s;
import java.awt.Color;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static Color[] getGradientBrightColors(Color baseColor,
            float step, float max) {
        List<Color> list = new ArrayList<Color>();
        float color[] = Color.RGBtoHSB(baseColor.getRed(),
                baseColor.getGreen(), baseColor.getBlue(), null);

        list.add(baseColor);/*  w w w.  ja  v a2 s .c  o m*/

        for (; (color[2] += step) < (max);) {
            list.add(Color.getHSBColor(color[0], color[1], color[2]));
        }

        return list.toArray(new Color[] {});
    }
}

Related Tutorials