1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
/* 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
Add Comment