我想繪製Java中的RGB色輪,但無法通過圓形獲得漸變。我只是想在屏幕上繪製它,根本沒有用戶交互。如何在Java中繪製RGB色輪
這是我對現在:
public void paint (Graphics g){
super.paint(g);
int red = 255;
int green = 0;
int blue = 0;
int x1 = 500;
int y1 = 305;
int x2 = 500;
int y2 = 50;
while (green != 255){
g.setColor(new Color(red, green, blue));
green++;
g.drawLine(x1, y1, x2, y2);
x2++;
if (y2 < y1){
y2++;
}
}
while (red != 0){
g.setColor(new Color(red, green, blue));
red--;
g.drawLine(x1, y1, x2, y2);
x2--;
y2++;
}
x2 = 500;
while (blue != 255){
g.setColor(new Color(red, green, blue));
blue++;
g.drawLine(x1, y1, x2, y2);
x2--;
if (y2 > y1){
y2--;
}
}
while (red != 255){
green--;
g.setColor(new Color(red, green, blue));
red++;
g.drawLine(x1, y1, x2, y2);
x2++;
y2--;
}
}
}
Which draws the gradient like this
http://www.dickbaldwin.com/java/Java355.htm點擊這裏 – imoteb