创建使用HSB色彩的Java对象中的值
问题描述:
我想使用创建使用HSB值的颜色对象,但我有一些麻烦。创建使用HSB色彩的Java对象中的值
for(int i = 0; i<255; i++)
{
Color c = Color.getHSBColor(i,100,100);
System.out.println(c);
}
我希望它可以通过所有色相旋转,而是每个颜色都有RGB的相同RGB值(251,251,2)
输出是
java.awt.Color[r=251,g=251,b=2]
java.awt.Color[r=251,g=251,b=2]
java.awt.Color[r=251,g=251,b=2]
....
任何想法我做错了? 由于
答
从颜色#getHSBColor(浮点,浮点,浮点)的javadocs中:
The <code>s</code> and <code>b</code> components should be
floating-point values between zero and one
(numbers in the range 0.0-1.0). The <code>h</code> component
can be any floating-point number. The floor of this number is
subtracted from it to create a fraction between 0 and 1.
换句话说,该值不为0的范围内 - 255,但是从0.0 - 1.0。