get Color Hue - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

get Color Hue

Demo Code

/** Copyright by Barry G. Becker, 2000-2011. Licensed under MIT License: http://www.opensource.org/licenses/MIT  */
//package com.java2s;
import java.awt.*;

public class Main {
    /**//from w  w  w  .j a va2s. c om
     *
     * @param color
     * @return the hue (in HSB space) for a given color.
     */
    public static float getColorHue(Color color) {
        float[] hsv = Color.RGBtoHSB(color.getRed(), color.getGreen(),
                color.getBlue(), null);
        return hsv[0];
    }
}

Related Tutorials