2017-02-25 4 views
-1

HSB 값을 사용하여 Color 객체를 만들려고하는데 문제가 있습니다.HSB 값을 사용하여 Java Color 객체 생성

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 (플로트, 플로트, 플로트)의 JavaDoc을 가입일

답변

2

는 :

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.