代码实现如下:
float r = 120;
void setup() {
size(500, 500);
}
void draw() {
background(0);
pushMatrix();
translate(width/2, height/2);
noFill();
stroke(255, 50);
ellipse(0, 0, r*2, r*2);
//中间的圆球
for (float i=0; i<80; i+=0.05) {
float t = i+random(0.1, PI);
float x1 = r * cos(i);
float y1 = r * sin(i);
float x2 = r * cos(t);
float y2 = r * sin(t);
line(x1, y1, x2, y2);
}
//外圆-正向倾斜
float r2 = r+50;
ellipse(0, 0, r2, r2);
for (float i=0; i<40; i+=0.1) {
float t = i+random(0.1, PI/2);
float r_tmp = random(r+35,r2);
float x1 = r * cos(i);
float y1 = r * sin(i);
float x2 = r_tmp * cos(t);
float y2 = r_tmp * sin(t);
line(x1, y1, x2, y2);
fill(