Convert HSB To RGB Color Example
- /*
- Convert HSB To RGB Color Example
- This java example shows how to convert Hue, Saturation, and brightness
- model (HSB) to Red,Green, and Blue (RGB) model using Java AWT Color class.
- */
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Graphics;
- /*
- <applet code="ConvertHSBToRGBColor" width=200 height=100>
- </applet>
- */
- public class ConvertHSBToRGBColor extends Applet{
- public void paint(Graphics g){
- /*
- * To convert HSB to RGB, use
- * static int HSBtoRGB(float hue, float saturation, float brightness)
- * method of AWT Color class.
- *
- * This method returns RGB equivalent set of values.
- */
- int rgb = Color.HSBtoRGB(0.6f,0.5f,0.8f);
- //create new color from the RGB value
- Color color = new Color(rgb);
- //set foreground color of this applet
- this.setForeground(color);
- g.drawString("Color converted from HSB to RGB",10,50);
- }
- }
Example Output




