// colorf.java compile javac -cp . colorf.java public class colorf extends Object { // colorf color wheel based on parameter 0 <= x <=1 // colorf(X, RGB[]) returns R,G,B in 0.0 to 1.0 // 1/1/97 JSS initial version // converted to java public void colorf(double X, double rgb[]) // rgb new double[3] { double A, AA, AAA; // temporaries double R, G, B; // red, green, blue intensities A = 2.0*X-1.0; // -1.0 < A < 1.0 if(A<-1.0) A = -1.0; if(A>1.0) A = 1.0; R = 1.0 - Math.abs(A); AA = A - 2.0/3.0; if(AA < -1.0) AA = 2.0+AA; G = 1.0 - Math.abs(AA); AA = A + 2.0/3.0; if(AA > 1.0) AA = 2.0-AA; B = 1.0 - Math.abs(AA); // boost low end and normalize (this brightens colors) R = R+0.2; G = G+0.2; B = B+0.2; AAA = Math.max(R, G); AAA = Math.max(AAA, B); rgb[0] = R/AAA; rgb[1] = G/AAA; rgb[2] = B/AAA; } // end colorf } // end colorf.java