在标题中,我想为我的Julia套装添加2-3种颜色和阴影。 但我不知道该怎么做。我知道如何添加1种颜色,我就这么做了。但我必须加2-3。
import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;
import javax.swing.JApplet;
public class ComplexTester extends JApplet {
Color c;
public void init() {
resize(600, 600);
}
public Color setC1() {
c = new Color(250, 250, 0);
return c;
}
public void paint(Graphics g) {
Random generator = new Random();
Complex c = new Complex(-0.123, 0.745);
Complex b = new Complex();
for (int k = 0; k < 600; k++)
for (int j = 0; j < 600; j++) {
Complex a = new Complex((k / 200.0) - 1.5,
(600 - j) / 200.0 - 1.5);
int i = 0;
b = a;
do {
b = b.kwadrat().dodaj(c);
i++;
if (b.moduł2().getX() > 2)
break;
} while (i < 30);
if (i == 30) {
g.setColor(setC2());
g.drawOval(k, j, 1, 1);
}
}
}
}
setColor()方法只添加一种颜色。是否有添加少量颜色的方法?