get Saturation - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

get Saturation

Demo Code


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

public class Main {
    public static void main(String[] argv) throws Exception {
        int c = 2;
        System.out.println(getSaturation(c));
    }/*from   www .j ava 2s. c  om*/

    public static float hsb[];

    public static final float getSaturation(int c) {
        if (hsb == null)
            hsb = new float[3];
        Color.RGBtoHSB((c >> 16) & 0xff, (c >> 8) & 0xff, (c & 0xff), hsb);

        return hsb[1];
    }
}

Related Tutorials