I have completed some of the code for a color wheel, but I'm confused on how to complete it? I've also commented the code to help understand. So far, it prints red, orange and yellow gradients. How do I complete this?
import java.awt.*;
public class ColorDrawing2 {
public static final int CENTER = 256;
public static final int RADIUS = 120;
public static final int SHAPES = 32;
public static final int SIZE = 40;
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(512,512); // create a drawing panel
panel.setBackground(new Color(0,0,0)); // set background color (orange)
Graphics g = panel.getGraphics(); // get graphics toolkit
for (int i = 0; i <= SHAPES; i++) {
// System.out.println("i = " + i);
double angle = (i)*(360/SHAPES)*(Math.PI/180); // angle
// System.out.println("Angle = " + angle);
double x = CENTER - (SIZE/2) + RADIUS*Math.cos(angle); // x-cooordinate
double y = CENTER - (SIZE/2) + RADIUS*Math.sin(angle); // y-coordinate
int red = (int) (199 + 56/SHAPES*i); // 199 < red < 255
// System.out.println("Red = " + red);
int grn = (int) (7.97*i); // 0 < grn < 255
// System.out.println("Green = " + grn);
int blu = 0;
g.setColor(new Color((int) red, grn, blu));
g.fillOval((int)x, (int)y, SIZE, SIZE);
panel.sleep(200); // pause 200 msec
}
}
}
Yes, seems like 6 for loops should be enough. Maybe the colors should go up to 255?