Java Swing Tutorial - Java Color.RGBtoHSB(int r, int g, int b, float[] hsbvals)








Syntax

Color.RGBtoHSB(int r, int g, int b, float[] hsbvals) has the following syntax.

public static float[] RGBtoHSB(int r,  int g,  int b,  float[] hsbvals)

Example

In the following code shows how to use Color.RGBtoHSB(int r, int g, int b, float[] hsbvals) method.

import java.awt.Color;
import java.util.Arrays;
/* w  ww. ja  v  a 2s .co m*/
public class Main {
  public static void main() {
    int red = 23;
    int green = 66;
    int blue = 99;

    float[] hsb = Color.RGBtoHSB(red, green, blue, null);
    System.out.println(Arrays.toString(hsb));

  }
}

The code above generates the following result.