วันศุกร์ที่ 20 กันยายน พ.ศ. 2556

Solar System





int[ ] moon = {0, 0, 1, 2, 63, 62, 27, 15};
float[ ] distance = {0.4+.5, 0.7+.5, 1.0+.5, 1.4+.5, 3.0+.5, 4.7+.5, 6.3+.5,7.5+.5};
float[ ] Radius = {7.2, 18.0, 20.0, 10.6, 70.0, 50.0, 40.0, 35.0};
String[ ] names= {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"};
int n = 0;

void setup() {
  size(800, 500);
  background(0);
  smooth();
}
void draw() {
  fill(255,153,0);
  drawCircle(-550,height/2,1200);
  while (n < moon.length) {
     Star(90 * distance[n], height/2, Radius[n]);
     text(names[n],90 * distance[n] - 15 ,height/2 + 60 + (n * 10));
     n = n + 1;
  }
}

void Star(float x, int y, float r) {
  fill (random(255),random(255),random(255));
  drawCircle(x, y, r) ;
  int b = 1;
  while (b <= moon[n]) {
    float a = 360/moon[n];
    a = a * b;
    fill(random(255),random(255),random(255));
    drawCircle((r*cos(a))+x, ((r*sin(a))+y-(r*sin(90)))+r, 5);
    noFill();
    b = b + 1;
  }
}

void drawCircle(float x, float y, float r) {
  ellipse(x, y, r, r);
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น