Get hue from color - Android Graphics

Android examples for Graphics:Color Hue

Description

Get hue from color

Demo Code


//package com.java2s;
import android.graphics.Color;

public class Main {
    /**//from www  .ja v  a 2 s.com
     * Get hue from color
     * @param color color
     * @return color hue value, 0..360
     */
    public static float getHueFromColor(int color) {
        return getHSVFromColor(color)[0];
    }

    /**
     * Get HSV array from color
     * @param color color
     * @return HSV array, length = 3
     */
    public static float[] getHSVFromColor(int color) {
        float hsv[] = new float[3];
        Color.colorToHSV(color, hsv);
        return hsv;
    }
}

Related Tutorials