// colorw.java color wheel based on phase angle // copied from 1/1/97 JSS initial version // tested on Linux, MacOSX, Windows // may be compiled and linked using javac -cp . colorw.java import java.awt.*; import java.awt.event.*; import java.io.*; import java.*; public class colorw extends Frame { double Pi = 3.14159265358979323846; int width=400; int height=400; colorw() { setTitle("colorw.java"); setSize(width,height); setBackground(Color.white); setForeground(Color.black); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setVisible(true); repaint(); } // colorw public void paint(Graphics g) { double x1, x2, y1, y2; float A, AA, AAA; // temporaries float R, G, B; // red, green, blue intensities computer double radius_1 = 160.0; double radius_2 = 60.0; int cnt = 0; int ncont = 2; double xc = 200.0; double yc = 210.0; g.setColor(Color.black); // for(int i=0; i 1.0f) AA = 2.0f-AA; B = (float)(1.0 - Math.abs(AA)); // boost low end and normalize (this brightens colors) R = R+0.2f; G = G+0.2f; B = B+0.2f; AAA = Math.max(R, G); AAA = Math.max(AAA, B); R = R/AAA; G = G/AAA; B = B/AAA; // set color g.setColor(new Color(R, G, B)); // compute line ends x1 = radius_1 * Math.cos(A * Pi); y1 = radius_1 * Math.sin(A * Pi); x2 = radius_2 * Math.cos(A * Pi); y2 = radius_2 * Math.sin(A * Pi); g.drawLine((int)(xc+x1), (int)(yc+y1), (int)(xc+x2), (int)(yc+y2)); A = A + 0.005f; // 240 lines, 0.01 200 lines -1.0 to 1.0 } } // end paint public static void main(String args[]) { new colorw(); } } // end colorw.java